/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:PMModuleLogicDAL.cs * 2.功能描述:生产管理数据库访问类(插入、修改、删除) * 编辑履历: * 作者 日期 版本 修改内容 * 陈冰 2014/09/17 1.00 新建 *******************************************************************************/ using System; using System.Collections.Generic; using System.Data; using System.Text; using Dongke.IBOSS.PRD.Basics.BaseResources; using Dongke.IBOSS.PRD.Basics.DataAccess; using Dongke.IBOSS.PRD.Basics.Library; using Dongke.IBOSS.PRD.Service.DataModels; using Dongke.IBOSS.PRD.WCF.DataModels; using Oracle.DataAccess.Client; namespace Dongke.IBOSS.PRD.Service.PMModuleLogic { /// /// 生产管理数据库访问类(插入、修改、删除) /// public partial class PMModuleLogicDAL { #region 生产管理 #region 计件 /// /// 添加生产计件 /// /// 工序ID /// 条码信息 /// 用户基本信息 /// DataTable null:添加成功 不为空:错误消息 /// /// 陈冰 2014.09.18 新建 /// public static DataTable AddWorkPiece(int procedureID, DataTable barcodeTable, SUserInfo sUserInfo, out ProcedureEntity procedureInfo) { procedureInfo = null; // 实例返回的Talbe DataTable dtBarCode = PMModuleLogic.CreateBarCodeResultTable(); DataRow dr = dtBarCode.NewRow(); string errMsg = ""; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); oracleTrConn.IgnoreCase = false; try { DataSet dsReturnSinglePoint = null; oracleTrConn.Connect(); int goodsID = Constant.INT_IS_ZERO; string goodsCode = null; string goodsName = null; string groutingUserCode = string.Empty; string logoCode = string.Empty; string logoName = string.Empty; string groutingdate = string.Empty; #region 查询工序信息 ProcedureEntity procedure = GetProcedurByID(oracleTrConn, procedureID); procedureInfo = procedure; #endregion if (barcodeTable.Columns.Contains("IsPDA")) { if (procedure.ModelType != (int)Constant.ProcedureModelType.DeliverMud) { if (barcodeTable.Columns.Contains("IsPublicBody")) { barcodeTable.Columns.Remove("IsPublicBody"); barcodeTable.Columns.Remove("IsPDA"); } } } #region 防止多次重复提交,导致数据重复 // 通过锁定表tp_pm_usedbarcode中的条码,防止多次重复提交,导致数据重复 // TODO PDA还没有修改,暂时注释。PDA(集中采集画面)点击保存时如果不成功提示消息后,清除了当前画面中的数据。应该不清空数据,可以继续保存。 //string barcodes = null; //foreach (DataRow item in barcodeTable.Rows) //{ // if (barcodes != null) // { // barcodes += ","; // } // barcodes += item["Barcode"].ToString(); //} //if (barcodes != null) //{ // string sql = "select uc.barcode from tp_pm_usedbarcode uc where uc.barcode in (" + barcodes + ") for update nowait"; // try // { // oracleTrConn.GetSqlResultToDt(sql); // } // catch (Exception ex) // { // // 判断异常类型 // if (ex.Message.IndexOf("ORA-00054") > -1) // { // dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "条码正在被处理中,请稍后再操作。"; // dr[Constant.BarCodeResultTableColumns.out_missFlag.ToString()] = "0"; // dtBarCode.Rows.Add(dr); // return dtBarCode; // } // throw ex; // } //} #endregion #region 标准计件和坯库 if (procedure.ModelType == (int)Constant.ProcedureModelType.Normal || procedure.ModelType == (int)Constant.ProcedureModelType.AdobeStock) { if (procedure.CollectType == 1) { errMsg = AddNormalWorkPiece(oracleTrConn, procedure, barcodeTable, sUserInfo, out goodsID, out goodsCode, out goodsName, out groutingUserCode); } else { //单点 dsReturnSinglePoint = PMModuleLogic.CheckBarcodeSinglePoint(procedureID, barcodeTable.Rows[0]["barcode"].ToString(), sUserInfo); if (dsReturnSinglePoint != null) { if (dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() == "" && dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0") { goodsID = Convert.ToInt32(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()].ToString()); goodsCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString(); goodsName = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString(); groutingUserCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString(); barcodeTable.Rows[0]["barcode"] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_barcode.ToString()]; errMsg = AddNormalWorkPieceSinglePoint(oracleTrConn, procedure, barcodeTable, sUserInfo, goodsID, goodsCode, goodsName, groutingUserCode, null); } } } } #endregion #region 交坯 else if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud) { if (procedure.CollectType == 1) { errMsg = AddNormalWorkPiece(oracleTrConn, procedure, barcodeTable, sUserInfo, out goodsID, out goodsCode, out goodsName, out groutingUserCode); } else { int? GroutingDailyDetailID = null; dsReturnSinglePoint = PMModuleLogic.CheckBarcodeDeliverMudSinglePoint(procedureID, barcodeTable.Rows[0]["barcode"].ToString(), sUserInfo, ref GroutingDailyDetailID); if (dsReturnSinglePoint != null) { //if (barcodeTable.Rows[0]["UserCode"].ToString() != dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString()) //{ // dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "成型工号与交坯工号不一致,不允许交坯"; //} //else //{ if (dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() == "" && dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0") { if (procedure.DeliverType == 0) //手动模式 { if (barcodeTable.Rows[0]["UserCode"].ToString() != dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString()) { if (barcodeTable.Rows[0]["IsPublicBody"].ToString() != "1") { dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "成型工号与交坯工号不一致,不允许交坯"; } else { goodsID = Convert.ToInt32(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()].ToString()); goodsCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString(); goodsName = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString(); groutingUserCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString(); errMsg = AddNormalWorkPieceSinglePoint(oracleTrConn, procedure, barcodeTable, sUserInfo, goodsID, goodsCode, goodsName, groutingUserCode, GroutingDailyDetailID); if (!string.IsNullOrEmpty(errMsg)) { dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = errMsg; } // wangx 2016-10-10 是否设置过期未交坯 else { // string sqlNew = "select settingvalue from TP_MST_SystemSetting where settingcode='" + Constant.SettingType.S_PM_002.ToString() + "' and accountid=" + sUserInfo.AccountID; string sqlNew = "select deliverlimitCycle from TP_MST_Goods where goodsid=" + goodsID; string sqlSettingValue = oracleTrConn.GetSqlResultToStr(sqlNew); if (sqlSettingValue != "0") { ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel( Convert.ToDateTime(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]), Convert.ToInt32(sqlSettingValue), Constant.SettingType.S_PM_002.ToString(), sUserInfo); if (Convert.ToInt32(resultEntity.Result) < 0) { dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = resultEntity.Message; errMsg = resultEntity.Message; } } // wangx end } } } else { goodsID = Convert.ToInt32(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()].ToString()); goodsCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString(); goodsName = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString(); groutingUserCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString(); errMsg = AddNormalWorkPieceSinglePoint(oracleTrConn, procedure, barcodeTable, sUserInfo, goodsID, goodsCode, goodsName, groutingUserCode, GroutingDailyDetailID); if (!string.IsNullOrEmpty(errMsg)) { dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = errMsg; } // wangx 2016-10-10 是否设置过期未交坯 else { // string sqlNew = "select settingvalue from TP_MST_SystemSetting where settingcode='" + Constant.SettingType.S_PM_002.ToString() + "' and accountid=" + sUserInfo.AccountID; string sqlNew = "select deliverlimitCycle from TP_MST_Goods where goodsid=" + goodsID; string sqlSettingValue = oracleTrConn.GetSqlResultToStr(sqlNew); if (sqlSettingValue != "0") { ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel( Convert.ToDateTime(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]), Convert.ToInt32(sqlSettingValue), Constant.SettingType.S_PM_002.ToString(), sUserInfo); if (Convert.ToInt32(resultEntity.Result) < 0) { dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = resultEntity.Message; errMsg = resultEntity.Message; } } // wangx end } } } else //2016-07-05 { // 自动模式 .查出型工号,单点采集前台并没有传值,更新barcodeTable表对应的字段 string sql = @"select tp_mst_user.userid,tp_mst_user.usercode,tp_mst_user.username from TP_PM_GroutingDailyDetail left join tp_mst_user on TP_PM_GroutingDailyDetail.userid=tp_mst_user.userid where TP_PM_GroutingDailyDetail.barcode='" + barcodeTable.Rows[0]["barcode"].ToString() + "'"; DataSet ds = oracleTrConn.GetSqlResultToDs(sql); if (ds != null && ds.Tables[0].Rows.Count > 0) { barcodeTable.Rows[0]["UserCode"] = ds.Tables[0].Rows[0]["UserCode"]; barcodeTable.Rows[0]["UserID"] = ds.Tables[0].Rows[0]["UserID"]; barcodeTable.Rows[0]["UserName"] = ds.Tables[0].Rows[0]["UserName"]; } goodsID = Convert.ToInt32(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()].ToString()); goodsCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString(); goodsName = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString(); groutingUserCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString(); errMsg = AddNormalWorkPieceSinglePoint(oracleTrConn, procedure, barcodeTable, sUserInfo, goodsID, goodsCode, goodsName, groutingUserCode, GroutingDailyDetailID); if (!string.IsNullOrEmpty(errMsg)) { dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = errMsg; } // wangx 2016-10-10 是否设置过期未交坯 else { // string sqlNew = "select settingvalue from TP_MST_SystemSetting where settingcode='" + Constant.SettingType.S_PM_002.ToString() + "' and accountid=" + sUserInfo.AccountID; string sqlNew = "select deliverlimitCycle from TP_MST_Goods where goodsid=" + goodsID; string sqlSettingValue = oracleTrConn.GetSqlResultToStr(sqlNew); if (sqlSettingValue != "0") { ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel( Convert.ToDateTime(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]), Convert.ToInt32(sqlSettingValue), Constant.SettingType.S_PM_002.ToString(), sUserInfo); if (Convert.ToInt32(resultEntity.Result) < 0) { dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = resultEntity.Message; errMsg = resultEntity.Message; } } // wangx end } // } //} } } } } #endregion #region 装窑车 else if (procedure.ModelType == (int)Constant.ProcedureModelType.LoadCar) { errMsg = AddLoadKilnCar(oracleTrConn, procedure, barcodeTable, sUserInfo, out goodsID, out goodsCode, out goodsName); } #endregion #region 窑车补件 else if (procedure.ModelType == (int)Constant.ProcedureModelType.CarAdd) { errMsg = AddKilnCarSupplement(oracleTrConn, procedure, barcodeTable, sUserInfo, out goodsID, out goodsCode, out goodsName); } #endregion #region 入窑 else if (procedure.ModelType == (int)Constant.ProcedureModelType.IntoKiln) { // PDA传入的窑车号。没有传入条码信息 需要转换 /* modify by chenxy 2016-04-05 begin * 入窑画面显示条码后,登窑画面再做撤销登车,入窑再保存时,撤销的产品也到了入窑工序。 * 入窑时窑车上的产品需要重新获取。 */ //if (barcodeTable.Columns.Contains("IsPDAFlag")) // modify by chenxy 2016-04-05 end { barcodeTable = CarNoInfoConvertToTable(oracleTrConn, barcodeTable, sUserInfo); } errMsg = AddIntoKilnCar(oracleTrConn, procedure, barcodeTable, sUserInfo, out goodsID, out goodsCode, out goodsName); } #endregion #region 出窑 else if (procedure.ModelType == (int)Constant.ProcedureModelType.OutKiln) { // PDA传入的窑车号。没有传入条码信息 需要转换 /* modify by chenxy 2016-04-05 begin * 入窑画面显示条码后,登窑画面再做撤销登车,入窑再保存时,撤销的产品也到了入窑工序。 * 入窑时窑车上的产品需要重新获取。 */ //if (barcodeTable.Columns.Contains("IsPDAFlag")) // modify by chenxy 2016-04-05 end { barcodeTable = CarNoInfoConvertToTable(oracleTrConn, barcodeTable, sUserInfo); } errMsg = AddOutKilnCar(oracleTrConn, procedure, barcodeTable, sUserInfo, out goodsID, out goodsCode, out goodsName); } #endregion #region 卸窑车 else if (procedure.ModelType == (int)Constant.ProcedureModelType.UnloadCar) { // PDA传入的窑车号。没有传入条码信息 需要转换 /* modify by chenxy 2016-04-05 begin * 入窑画面显示条码后,登窑画面再做撤销登车,入窑再保存时,撤销的产品也到了入窑工序。 * 入窑时窑车上的产品需要重新获取。 */ //if (barcodeTable.Columns.Contains("IsPDAFlag")) // modify by chenxy 2016-04-05 end { barcodeTable = CarNoInfoConvertToTable(oracleTrConn, barcodeTable, sUserInfo); } errMsg = AddUnloadingKilnCar(oracleTrConn, procedure, barcodeTable, sUserInfo, out goodsID, out goodsCode, out goodsName); } #endregion #region 干补 else if (procedure.ModelType == (int)Constant.ProcedureModelType.SpecialRepair) { errMsg = AddDryRepairWorkPiece(oracleTrConn, procedure, barcodeTable, sUserInfo, out goodsID, out goodsCode, out goodsName, out groutingUserCode, out logoCode, out logoName, out groutingdate); } #endregion #region 回收 else if (procedure.ModelType == (int)Constant.ProcedureModelType.Recovery) { errMsg = AddRecydingFlagWorkPiece(oracleTrConn, procedure, barcodeTable, sUserInfo, out goodsID, out goodsCode, out goodsName, out groutingUserCode, out logoCode, out logoName, out groutingdate); } #endregion #region 构造返回的DataTable if ((procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud || procedure.ModelType == (int)Constant.ProcedureModelType.Normal) && procedure.CollectType == 2) { dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()]; dr[Constant.BarCodeResultTableColumns.out_goodsID.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()]; dr[Constant.BarCodeResultTableColumns.out_goodsCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()]; dr[Constant.BarCodeResultTableColumns.out_goodsName.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()]; dr[Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()]; dr[Constant.BarCodeResultTableColumns.out_missFlag.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()]; //新添加的 dr[Constant.BarCodeResultTableColumns.out_groutingNum.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()]; dr[Constant.BarCodeResultTableColumns.out_mouldCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()]; dr[Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()]; dr[Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()]; dr[Constant.BarCodeResultTableColumns.out_groutingdate.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]; dr[Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()]; dr[Constant.BarCodeResultTableColumns.out_isReFire.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_isReFire.ToString()]; dr[Constant.BarCodeResultTableColumns.out_logoID.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()]; dr[Constant.BarCodeResultTableColumns.out_logoCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()]; dr[Constant.BarCodeResultTableColumns.out_logoName.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()]; dr[Constant.BarCodeResultTableColumns.out_barcode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_barcode.ToString()]; dr[Constant.BarCodeResultTableColumns.out_WaterLabelCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_WaterLabelCode.ToString()]; dr[Constant.BarCodeResultTableColumns.out_CodeCheckFlag.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_CodeCheckFlag.ToString()]; } else { dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = (errMsg == null ? "" : errMsg); dr[Constant.BarCodeResultTableColumns.out_goodsID.ToString()] = goodsID; dr[Constant.BarCodeResultTableColumns.out_goodsCode.ToString()] = goodsCode; dr[Constant.BarCodeResultTableColumns.out_goodsName.ToString()] = goodsName; dr[Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()] = groutingUserCode; dr[Constant.BarCodeResultTableColumns.out_logoCode.ToString()] = logoCode; dr[Constant.BarCodeResultTableColumns.out_logoName.ToString()] = logoName; dr[Constant.BarCodeResultTableColumns.out_groutingdate.ToString()] = groutingdate; //dr[Constant.BarCodeResultTableColumns.out_groutingNum.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()]; //dr[Constant.BarCodeResultTableColumns.out_mouldCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()]; //dr[Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()]; //dr[Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()]; //dr[Constant.BarCodeResultTableColumns.out_groutingdate.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]; //dr[Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()]; //dr[Constant.BarCodeResultTableColumns.out_isReFire.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_isReFire.ToString()]; //dr[Constant.BarCodeResultTableColumns.out_logoID.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()]; //dr[Constant.BarCodeResultTableColumns.out_logoCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()]; //dr[Constant.BarCodeResultTableColumns.out_logoName.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()]; } dtBarCode.Rows.Add(dr); #endregion // 没有错误 提交事务 if (string.IsNullOrEmpty(errMsg)) { oracleTrConn.Commit(); } } catch (Exception ex) { oracleTrConn.Rollback(); throw ex; } finally { // 释放资源 if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Disconnect(); } } return dtBarCode; } #region 是否公坯 /// /// 是否公坯 /// /// 产品条码 /// int public static int IsPubilcByBarCode(IDBTransaction oracleTrConn, string barcode) { int isPubilcBody = 0; try { string sqlString = @" select ispublicbody from tp_pm_inproduction where barcode=:barcode union select ispublicbody from TP_PM_InProductionTrash where barcode=:barcode "; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; DataSet ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); if (ds != null && ds.Tables[0].Rows.Count > 0) { isPubilcBody = Convert.ToInt32(ds.Tables[0].Rows[0]["ispublicbody"]); } return isPubilcBody; } catch (Exception ex) { throw ex; } } #endregion /// /// 标准计件 /// /// 数据连接对象 /// 工序对象 /// 条码信息 /// 用户基本信息 /// 返回的产品ID /// 返回的产品Code /// 返回的产品名称 /// 返回的注浆者ID /// string /// /// 陈冰 2014.09.18 新建 /// private static string AddNormalWorkPiece(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo, out int goodsID, out string goodsCode, out string goodsName, out string groutingUserCode) { try { goodsID = Constant.INT_IS_ZERO; goodsCode = null; goodsName = null; groutingUserCode = string.Empty; //Constant.INT_IS_ZERO; // 获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); string errMsg = string.Empty; // 本批采集的批次号 string centralizedBatchNo = System.Guid.NewGuid().ToString(); string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo; // 条码信息 foreach (DataRow barcodeRow in barcodeTable.Rows) { // 条码 string barcode = barcodeRow["Barcode"].ToString(); if (string.IsNullOrEmpty(barcode)) { throw new Exception("传入的条码号为空"); } // 生产工号 int workUserID = Convert.ToInt32(barcodeRow["UserID"]); // 生产工号 string workUserCode = barcodeRow["UserCode"].ToString(); int? GroutingDailyDetailID = null;//注浆明细ID if (procedure.CollectType == 1) { if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的 { #region 校验条码有效性 errMsg = CheckBarcodeDeliverMud(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo, ref GroutingDailyDetailID); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } else { #region 校验条码有效性 errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } } else { string sqlGroutingInfo = ""; sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid, tp_pm_groutingdailydetail.goodscode, tp_pm_groutingdailydetail.goodsname, tp_pm_groutingdailydetail.usercode as groutingUserCode, tp_pm_groutingdailydetail.GroutingDailyDetailID from tp_pm_groutingdailydetail where barcode = :barcode"; // from tp_pm_groutingdailydetail where groutingdailydetailid in //(select groutingdailydetailid from TP_PM_USEDBARCODE where barcode=:barcode)"; OracleParameter[] ReFireparas = new OracleParameter[] { new OracleParameter(":barcode",barcode), }; DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, ReFireparas); if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0) { GroutingDailyDetailID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["GroutingDailyDetailID"]); goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]); goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString(); goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString(); groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString(); } } int? ClassesSettingID = null;//班次配置ID #region 添加生产者数据 //生产数据ID string sql = "select SEQ_PM_ProductionData_ID.nextval from dual"; int productionDataID = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sql)); if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的 { string GroutingUserCode = barcodeRow["GroutingUserCode"].ToString(); if (GroutingUserCode.ToLower() == workUserCode.ToLower()) { //errMsg = AddProducerDeliverAdobe(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo); } else { errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID); } } else { errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID); } if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 添加生产数据 ProductionDataEntity productionData = new ProductionDataEntity(); #region 属性赋值 productionData.GroutingDailyDetailID = GroutingDailyDetailID;//只有交坯的时候用到 productionData.ClassesSettingID = ClassesSettingID; productionData.ProductionDataID = productionDataID; productionData.Barcode = barcode; productionData.CentralizedBatchNo = centralizedBatchNo; productionData.ProductionLineID = procedure.ProductionLineID; productionData.ProductionLineCode = procedure.ProductionlineCode; productionData.ProductionLineName = procedure.ProductionlineName; productionData.CompleteProcedureID = procedure.ProcedureID; productionData.ProcedureCode = procedure.ProcedureCode; productionData.ProcedureName = procedure.ProcedureName; productionData.ProcedureModel = procedure.ProcedureModel; productionData.ModelType = procedure.ModelType; productionData.NodeType = procedure.NodeType; productionData.PieceType = procedure.PieceType; if (barcodeRow["LogoID"].ToString() != "") { productionData.LogoID = Convert.ToInt32(barcodeRow["LogoID"]); } if (procedure.IsSpecialRework == 0) { productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects; //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态 //string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')"; if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)//是交坯节点,肯定不会是重烧 { productionData.IsReFire = (int)Constant.ReFireFlag.No; productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects; } ////// else ////// { ////// string sqlReFire = @"select ////// isrefire ////// from tp_pm_inproduction where barcode=:barcode ////// "; ////// OracleParameter[] ReFireparas = new OracleParameter[] { ////// new OracleParameter(":barcode",barcode), ////// }; ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas); ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0) ////// { ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0) ////// { ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]); ////// //if (productionData.IsReFire == 6) wangxin modify 20150422 因为已经大于0,定是重烧,即有缺陷 ////// //{ ////// productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect; ////// //} ////// } ////// } ////// } } else { productionData.IsReFire = (int)Constant.GoodsLevelType.ReFire; productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect; } productionData.ReworkProcedureID = null; #region 交坯判断 // 交坯节点 if (barcodeTable.Columns.Contains("IsPublicBody")) { productionData.IsPublicBody = Convert.ToInt32(barcodeRow["IsPublicBody"]); } // 非交坯节点 else { // 正常坯 productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode); } #endregion productionData.OrganizationID = procedure.OrganizationID; productionData.GoodsID = goodsID; productionData.GoodsCode = goodsCode; productionData.GoodsName = goodsName; productionData.UserID = workUserID; productionData.UserCode = barcodeRow["UserCode"].ToString(); productionData.UserName = barcodeRow["UserName"].ToString(); #endregion string OutSpecialRepairflag = "0";//干补标识 DataSet outDataSet = null; if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { errMsg = AddProductionDataDeliverMud(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, out outDataSet); } else { errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); } if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 开始节点 if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { #region 添加在产产品数据 InProductionEntity addInProductionEntity = new InProductionEntity(); addInProductionEntity.BarCode = barcode; //流程工序ID addInProductionEntity.FlowProcedureID = procedure.ProcedureID; // 当前工序 addInProductionEntity.ProcedureID = procedure.ProcedureID; //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID; // 工序模型 addInProductionEntity.ProcedureModel = procedure.ProcedureModel; // 工序类别 addInProductionEntity.ModelType = procedure.ModelType; addInProductionEntity.SpecialRepairflag = Convert.ToInt32(OutSpecialRepairflag);//干补标识 addInProductionEntity.ProductionDataID = productionDataID; #region 交坯判断 addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯 #endregion // 生产工号 addInProductionEntity.UserID = workUserID; // 执行添加 errMsg = AddInProduction(oracleTrConn, addInProductionEntity, sUserInfo, outDataSet); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion #region 中间节点 else if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle) { #region 修改在产产品数据的当前工序,清空返工工序字段 InProductionEntity addInProductionEntity = new InProductionEntity(); addInProductionEntity.BarCode = barcode; //流程工序ID addInProductionEntity.FlowProcedureID = procedure.ProcedureID; // 当前工序 addInProductionEntity.ProcedureID = procedure.ProcedureID; //当前生产数据ID addInProductionEntity.ProductionDataID = productionDataID; // 工序模型 addInProductionEntity.ProcedureModel = procedure.ProcedureModel; // 工序类别 addInProductionEntity.ModelType = procedure.ModelType; // 生产工号 addInProductionEntity.UserID = workUserID; addInProductionEntity.LogoID = productionData.LogoID; // 缺陷标识 // addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No; //addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefect; if (procedure.IsSpecialRework == 0) { addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects; } else { addInProductionEntity.IsReFire = (int)Constant.GoodsLevelType.ReFire; addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects; } #region 交坯判断 addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯 #endregion // 执行修改 errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion #region 结束节点 else { #region 添加成品数据 删除在产产品数据 FinishedProductEntity finishedProduct = new FinishedProductEntity(); finishedProduct.BarCode = barcode; finishedProduct.LogoID = productionData.LogoID; errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } InProductionEntity delInProductionEntity = new InProductionEntity(); delInProductionEntity.BarCode = barcode; // 执行删除 在产数据 errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion } return errMsg; } catch (Exception ex) { throw ex; } } /// /// 添加生产者(交坯单独调用,特殊) /// /// 连接对象 /// 账务日期 /// 生产数据ID /// 生产工号ID /// 生产工号Code /// 用户基本信息 /// string private static string AddProducerDeliverAdobe(IDBTransaction oracleTrConn, DateTime accountDate, int productionDataID, int workUserID, string workUserCode, SUserInfo sUserInfo) { // 参数 OracleParameter[] paras; #region 将班次配置表中的数据插入生产者表中 string sql = "insert into tp_pm_producer" + " (productiondataid," + " staffid," + " userid," + " usercode," + " UJobsID," + " staffstatus," + " SJobsID" + " )" + " select distinct :productiondataid," + " staffid," + " userid," + " usercode," + " UJobsID," + " staffstatus," + " SJobsID" + " " + " from TP_PM_GroutingProducer" + " where UserID = :userID"; paras = new OracleParameter[] { new OracleParameter(":productiondataid",OracleDbType.Int32,productionDataID,ParameterDirection.Input), new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input), }; int resultCount = oracleTrConn.ExecuteNonQuery(sql, paras); // 失败 if (resultCount == Constant.INT_IS_ZERO) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } #endregion return null; } /// /// 装车后,更新所有以前操作的工序窑车信息 /// /// 连接对象 /// 条码 /// 窑车号 /// 产品ID /// 窑车位置 /// 装车批次 /// 用户基本信息 /// string private static string UpdateRefineBybarcode(IDBTransaction oracleTrConn, ProductionDataEntity productionData) { string sql = "update TP_PM_ProductionData set " + " IsReFire=:IsReFire" + " where barcode=:barcode"; #region 参数 OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":IsReFire",(int)Constant.GoodsLevelType.ReFire), new OracleParameter(":barcode",productionData.Barcode), }; #endregion int result = oracleTrConn.ExecuteNonQuery(sql, paras); // 保存失败 if (result == Constant.INT_IS_ZERO) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 保存成功返回null return null; } /// /// 装窑车计件 /// /// 数据连接对象 /// 工序对象 /// 条码信息 /// 用户基本信息 /// 返回的产品ID /// 返回的产品Code /// 返回的产品名称 /// string /// /// 陈冰 2014.09.18 新建 /// private static string AddLoadKilnCar(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo, out int goodsID, out string goodsCode, out string goodsName) { try { goodsID = Constant.INT_IS_ZERO; goodsCode = null; goodsName = null; string groutingUserCode = string.Empty; // 获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); string errMsg = string.Empty; // 生产工号 int workUserID = Constant.INT_IS_ZERO; // 生产工号Code string workUserCode = string.Empty; // 生产工号Name string workUserName = string.Empty; // 本批采集的批次号 string centralizedBatchNo = System.Guid.NewGuid().ToString(); // 窑车批次号 string kilnCarBatchNo = System.Guid.NewGuid().ToString(); // 窑车状态 string kilnCarStatus = string.Empty; ////////////////////////////////////////////////// DataView dv = barcodeTable.DefaultView; DataTable dtNewKiln = dv.ToTable(true, "kilnCarCode"); for (int i = 0; i < dtNewKiln.Rows.Count; i++) { DataRow[] dr = barcodeTable.Select("kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'"); // 窑炉ID //int kilnID = Convert.ToInt32(barcodeTable.Rows[0]["kilnID"].ToString()); int kilnID = Convert.ToInt32(dr[0]["kilnID"].ToString()); // 窑车ID //int kilnCarID = Convert.ToInt32(barcodeTable.Rows[0]["KilnCarID"].ToString()); int kilnCarID = Convert.ToInt32(dr[0]["KilnCarID"].ToString()); // 窑车Code // string kilnCarCode = barcodeTable.Rows[0]["kilnCarCode"].ToString(); string kilnCarCode = dr[0]["kilnCarCode"].ToString(); #region 校验窑车是否可装车 errMsg = CheckKilnCarrStatus(oracleTrConn, procedure.ProcedureID, kilnCarCode, procedure.ModelType, sUserInfo, out kilnCarStatus); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 如果窑车状态为空,需要插入窑车状态表 if (string.IsNullOrEmpty(kilnCarStatus)) { // 插入窑车状态表 errMsg = AddkilnCarStatus(oracleTrConn, procedure, kilnCarID, kilnID, kilnCarBatchNo, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } } #endregion #region 窑车表存在,查询本次窑车产品的批次号 并更改装窑车时间 // 查询本次窑车产品的批次号 else { kilnCarBatchNo = GetKilnCarBatchNoByKilnCarID(oracleTrConn, kilnCarID); // 更改窑车状态表入窑时间 errMsg = UpdatekilnCarStatus(oracleTrConn, kilnCarID, Constant.ProcedureModelType.LoadCar, sUserInfo, procedure, kilnCarBatchNo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } } #endregion // 条码信息 DataView dvFilter = barcodeTable.DefaultView; dvFilter.RowFilter = "kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'"; DataTable dtNew = dvFilter.ToTable(); // 条码信息 //foreach (DataRow barcodeRow in barcodeTable.Rows) //-------------------------------- string sqllast = "select max(createtime) as createtime from TP_PM_KilnCarGoods" + " where KilnCarID=:KilnCarID and AccountID=:AccountID"; OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":KilnCarID",kilnCarID), new OracleParameter(":AccountID",sUserInfo.AccountID), }; DataSet dsReturn = oracleTrConn.GetSqlResultToDs(sqllast, paras); object lastcreatetime = null; if (dsReturn != null && dsReturn.Tables[0].Rows.Count > 0 && dsReturn.Tables[0].Rows[0]["CreateTime"].ToString() != "") { lastcreatetime = Convert.ToDateTime(dsReturn.Tables[0].Rows[0]["CreateTime"]); } //-------------------------------- int? maxClassesSettingID = null; foreach (DataRow barcodeRow in dtNew.Rows) { // 条码 string barcode = barcodeRow["Barcode"].ToString(); // 生产工号 workUserID = Convert.ToInt32(barcodeRow["UserID"]); workUserCode = barcodeRow["UserCode"].ToString(); workUserName = barcodeRow["UserName"].ToString(); #region 校验条码有效性 errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion // 查询新插入的生产数据ID string sql = "select SEQ_PM_ProductionData_ID.nextval from dual"; string idStr = oracleTrConn.GetSqlResultToStr(sql); int productionDataID = 0; if (!string.IsNullOrEmpty(idStr)) { productionDataID = int.Parse(idStr); } else { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } int? ClassesSettingID = null;//班次配置ID #region 添加生产者数据 errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion maxClassesSettingID = ClassesSettingID; #region 添加生产数据 ProductionDataEntity productionData = new ProductionDataEntity(); #region 属性赋值 productionData.ClassesSettingID = ClassesSettingID; productionData.ProductionDataID = Convert.ToInt32(idStr); productionData.Barcode = barcode; productionData.CentralizedBatchNo = centralizedBatchNo; productionData.ProductionLineID = procedure.ProductionLineID; productionData.ProductionLineCode = procedure.ProductionlineCode; productionData.ProductionLineName = procedure.ProductionlineName; productionData.CompleteProcedureID = procedure.ProcedureID; productionData.ProcedureCode = procedure.ProcedureCode; productionData.ProcedureName = procedure.ProcedureName; productionData.ProcedureModel = procedure.ProcedureModel; productionData.ModelType = procedure.ModelType; productionData.NodeType = procedure.NodeType; productionData.ReworkProcedureID = null; productionData.PieceType = procedure.PieceType; //productionData.IsPublicBody = (int)Constant.PublicBodyFlag.No; if (procedure.IsSpecialRework == 0) { productionData.IsReFire = (int)Constant.ReFireFlag.No; productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects; } else { productionData.IsReFire = (int)Constant.GoodsLevelType.ReFire; productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect; } //productionData.GoodsGrade = (int)Constant.GoodsLevelType.NoDefects; //if (lastcreatetime != null) //{ // productionData.CreateTime = Convert.ToDateTime(lastcreatetime); //} //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态 ////string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')"; ////DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire); ////if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0) ////{ //// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0) //// { //// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]); //// } ////} productionData.OrganizationID = procedure.OrganizationID; productionData.GoodsID = goodsID; productionData.GoodsCode = goodsCode; productionData.GoodsName = goodsName; productionData.UserID = workUserID; productionData.UserCode = barcodeRow["UserCode"].ToString(); productionData.UserName = barcodeRow["UserName"].ToString(); productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode); #region 窑炉窑车属性 productionData.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString()); productionData.KilnCode = barcodeRow["KilnCode"].ToString(); productionData.KilnName = barcodeRow["KilnName"].ToString(); productionData.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString()); productionData.KilnCarCode = barcodeRow["KilnCarCode"].ToString(); productionData.KilnCarName = barcodeRow["KilnCarName"].ToString(); productionData.KilnCarBatchNo = kilnCarBatchNo; productionData.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString()); #endregion #endregion string OutSpecialRepairflag = "0";//干补标识 //if (lastcreatetime == null) //{ errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); //} //else //{ // errMsg = AddProductionDataCreateTime(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); //} if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 修改在产产品数据的当前工序,清空返工工序字段 InProductionEntity addInProductionEntity = new InProductionEntity(); addInProductionEntity.BarCode = barcode; //流程工序 addInProductionEntity.FlowProcedureID = procedure.ProcedureID; // 当前工序 //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID; addInProductionEntity.ProcedureID = procedure.ProcedureID; //生产数据ID addInProductionEntity.ProductionDataID = productionDataID; // 工序模型 addInProductionEntity.ProcedureModel = procedure.ProcedureModel; // 工序类别 addInProductionEntity.ModelType = procedure.ModelType; // 生产工号 addInProductionEntity.UserID = workUserID; // 缺陷标识 //addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects; #region 更新在产表窑车窑炉字段 addInProductionEntity.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString()); addInProductionEntity.KilnCode = barcodeRow["KilnCode"].ToString(); addInProductionEntity.KilnName = barcodeRow["KilnName"].ToString(); addInProductionEntity.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString()); addInProductionEntity.KilnCarCode = barcodeRow["KilnCarCode"].ToString(); addInProductionEntity.KilnCarName = barcodeRow["KilnCarName"].ToString(); addInProductionEntity.KilnCarBatchNo = kilnCarBatchNo; addInProductionEntity.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString()); #endregion if (procedure.IsSpecialRework == 0) { addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects; } else { addInProductionEntity.IsReFire = (int)Constant.GoodsLevelType.ReFire; addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects; } // 执行修改 errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion //#region 添加生产者数据 //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} //#endregion //errMsg = UpdateKilnCarCreatetimeInfoBybarcode(oracleTrConn, productionData, sUserInfo); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} #region 插入窑车产品表 errMsg = AddKilnCarGoods(oracleTrConn, barcode, kilnCarID, goodsID, productionData.KilnCarPosition.Value, kilnCarBatchNo, workUserID, workUserCode, workUserName, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion //#region 装车后,更新所有以前操作的工序窑车信息 //errMsg = UpdateKilnCarInfoBybarcode(oracleTrConn, productionData); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} //#endregion } #region 窑车生产数据 #region 插入窑车生产数据表 if (lastcreatetime == null) //加此判断为的是,在登车时落产品,进行第二些登车时,不插重复数据 { errMsg = AddKilnCarData(oracleTrConn, accountDate, kilnCarID, kilnCarBatchNo, workUserID, workUserCode, workUserName, null, sUserInfo, maxClassesSettingID); #region 窑车生产者 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion #endregion } return errMsg; } catch (Exception ex) { throw ex; } } /// /// 装车后,更新所有以前操作的工序窑车信息 /// /// 连接对象 /// 条码 /// 窑车号 /// 产品ID /// 窑车位置 /// 装车批次 /// 用户基本信息 /// string private static string UpdateKilnCarInfoBybarcode(IDBTransaction oracleTrConn, ProductionDataEntity productionData) { string sql = "update TP_PM_ProductionData set " + " KilnID=:KilnID," + "KilnCode=:KilnCode," + "KilnName=:KilnName," + "KilnCarID=:KilnCarID," + "KilnCarCode=:KilnCarCode," + "KilnCarName=:KilnCarName," + "KilnCarBatchNo=:KilnCarBatchNo," + "KilnCarPosition=:KilnCarPosition," + "isrefire=:isrefire " + " where barcode=:barcode"; #region 参数 OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":KilnID",productionData.KilnID), new OracleParameter(":KilnCode",productionData.KilnCode), new OracleParameter(":KilnName",productionData.KilnName), new OracleParameter(":KilnCarID",productionData.KilnCarID), new OracleParameter(":KilnCarCode",productionData.KilnCarCode), new OracleParameter(":KilnCarName",productionData.KilnCarName), new OracleParameter(":KilnCarBatchNo",productionData.KilnCarBatchNo), new OracleParameter(":KilnCarPosition",productionData.KilnCarPosition), new OracleParameter(":isrefire",productionData.IsReFire), new OracleParameter(":barcode",productionData.Barcode), }; #endregion int result = oracleTrConn.ExecuteNonQuery(sql, paras); // 保存失败 if (result == Constant.INT_IS_ZERO) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 保存成功返回null return null; } /// /// 入窑车计件 /// /// 数据连接对象 /// 工序对象 /// 条码信息 /// 基本 /// 返回的产品ID /// 返回的产品Code /// 返回的产品名称 /// string /// /// 张国印 2014.10.04 新建 /// private static string AddIntoKilnCar(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo, out int goodsID, out string goodsCode, out string goodsName) { try { goodsID = Constant.INT_IS_ZERO; goodsCode = string.Empty; goodsName = string.Empty; string groutingUserCode = string.Empty; // 获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); string errMsg = string.Empty; // 生产工号 int workUserID = Constant.INT_IS_ZERO; // 生产工号Code string workUserCode = string.Empty; // 生产工号Name string workUserName = string.Empty; // 本批采集的批次号 string centralizedBatchNo = System.Guid.NewGuid().ToString(); // 窑车批次号 string kilnCarBatchNo = System.Guid.NewGuid().ToString(); // 窑车状态 string kilnCarStatus = string.Empty; ////////////////////////////////////////////////// DataView dv = barcodeTable.DefaultView; DataTable dtNewKiln = dv.ToTable(true, "kilnCarCode"); for (int i = 0; i < dtNewKiln.Rows.Count; i++) { /////////////////////////////////////////////////// // 窑车Code //string kilnCarCode = barcodeTable.Rows[0]["kilnCarCode"].ToString(); DataRow[] dr = barcodeTable.Select("kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'"); string kilnCarCode = dr[0]["kilnCarCode"].ToString(); #region 校验窑车是否可入窑炉 errMsg = CheckKilnCarrStatus(oracleTrConn, procedure.ProcedureID, kilnCarCode, procedure.ModelType, sUserInfo, out kilnCarStatus); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion // 窑炉ID //int kilnID = Convert.ToInt32(barcodeTable.Rows[0]["kilnID"].ToString()); int kilnID = Convert.ToInt32(dr[0]["kilnID"].ToString()); // 窑车ID //int kilnCarID = Convert.ToInt32(barcodeTable.Rows[0]["KilnCarID"].ToString()); int kilnCarID = Convert.ToInt32(dr[0]["KilnCarID"].ToString()); //备注信息 string Remarks = dr[0]["Remarks"].ToString(); // 主要目的防止输入窑车号,当前工序与该操作的工序不匹配,例如重烧入窑,在入窑工序上操作了 errMsg = GetKilnCarProcedureIDByKilnCarID(oracleTrConn, kilnCarID, Convert.ToInt32(procedure.ProcedureID)); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } // 查询本次窑车产品的批次号 kilnCarBatchNo = GetKilnCarBatchNoByKilnCarID(oracleTrConn, kilnCarID); #region 窑车表存在,查询本次窑车产品的批次号 并更改入窑车时间 //更改窑车状态表入窑时间 errMsg = UpdatekilnCarStatus(oracleTrConn, kilnCarID, Constant.ProcedureModelType.IntoKiln, sUserInfo, procedure, kilnCarBatchNo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion DataView dvFilter = barcodeTable.DefaultView; dvFilter.RowFilter = "kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'"; DataTable dtNew = dvFilter.ToTable(); int? maxClassesSettingID = null; // 条码信息 //foreach (DataRow barcodeRow in barcodeTable.Rows) foreach (DataRow barcodeRow in dtNew.Rows) { // 条码 string barcode = barcodeRow["Barcode"].ToString(); // 生产工号 workUserID = Convert.ToInt32(barcodeRow["UserID"]); workUserCode = barcodeRow["UserCode"].ToString(); workUserName = barcodeRow["UserName"].ToString(); // 查询新插入的生产数据ID string sql = "select SEQ_PM_ProductionData_ID.nextval from dual"; string idStr = oracleTrConn.GetSqlResultToStr(sql); int productionDataID = 0; if (!string.IsNullOrEmpty(idStr)) { productionDataID = int.Parse(idStr); } else { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } int? ClassesSettingID = null;//班次配置ID #region 添加生产者数据 errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion maxClassesSettingID = ClassesSettingID; #region 添加生产数据 ProductionDataEntity productionData = new ProductionDataEntity(); #region 属性赋值 productionData.ClassesSettingID = ClassesSettingID; productionData.ProductionDataID = Convert.ToInt32(idStr); productionData.Barcode = barcode; productionData.CentralizedBatchNo = centralizedBatchNo; productionData.ProductionLineID = procedure.ProductionLineID; productionData.ProductionLineCode = procedure.ProductionlineCode; productionData.ProductionLineName = procedure.ProductionlineName; productionData.CompleteProcedureID = procedure.ProcedureID; productionData.ProcedureCode = procedure.ProcedureCode; productionData.ProcedureName = procedure.ProcedureName; productionData.ProcedureModel = procedure.ProcedureModel; productionData.ModelType = procedure.ModelType; productionData.NodeType = procedure.NodeType; productionData.DefectFlag = (int)Constant.DefectFlag.No; productionData.ReworkProcedureID = null; productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode); productionData.IsReFire = (int)Constant.ReFireFlag.No; productionData.PieceType = procedure.PieceType; //productionData.GoodsGrade = (int)Constant.GoodsGrade.Good; //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态 // string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')"; ////// string sqlReFire = @"select ////// isrefire ////// from tp_pm_inproduction where barcode=:barcode ////// "; ////// OracleParameter[] ReFireparas = new OracleParameter[] { ////// new OracleParameter(":barcode",barcode), ////// }; ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas); ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0) ////// { ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0) ////// { ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]); ////// } ////// } productionData.OrganizationID = procedure.OrganizationID; productionData.GoodsID = Convert.ToInt32(barcodeRow["GoodsID"]); productionData.GoodsCode = barcodeRow["GoodsCode"].ToString(); productionData.GoodsName = barcodeRow["GoodsName"].ToString(); productionData.UserID = workUserID; productionData.UserCode = barcodeRow["UserCode"].ToString(); productionData.UserName = barcodeRow["UserName"].ToString(); #region 窑炉窑车属性 productionData.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString()); productionData.KilnCode = barcodeRow["KilnCode"].ToString(); productionData.KilnName = barcodeRow["KilnName"].ToString(); productionData.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString()); productionData.KilnCarCode = barcodeRow["KilnCarCode"].ToString(); productionData.KilnCarName = barcodeRow["KilnCarName"].ToString(); productionData.KilnCarBatchNo = kilnCarBatchNo; productionData.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString()); productionData.Remarks = ""; #endregion #endregion string OutSpecialRepairflag = "0";//干补标识 errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 修改在产产品数据的当前工序,清空返工工序字段 InProductionEntity addInProductionEntity = new InProductionEntity(); addInProductionEntity.BarCode = barcode; //流程工序 addInProductionEntity.FlowProcedureID = procedure.ProcedureID; // 当前工序 //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID; addInProductionEntity.ProcedureID = procedure.ProcedureID; //生产数据ID addInProductionEntity.ProductionDataID = productionDataID; // 工序模型 addInProductionEntity.ProcedureModel = procedure.ProcedureModel; // 工序类别 addInProductionEntity.ModelType = procedure.ModelType; // 生产工号 addInProductionEntity.UserID = workUserID; // 缺陷标识 addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No; #region 更新在产表窑车窑炉字段 addInProductionEntity.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString()); addInProductionEntity.KilnCode = barcodeRow["KilnCode"].ToString(); addInProductionEntity.KilnName = barcodeRow["KilnName"].ToString(); addInProductionEntity.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString()); addInProductionEntity.KilnCarCode = barcodeRow["KilnCarCode"].ToString(); addInProductionEntity.KilnCarName = barcodeRow["KilnCarName"].ToString(); addInProductionEntity.KilnCarBatchNo = kilnCarBatchNo; addInProductionEntity.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString()); #endregion // 执行修改 errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion //#region 添加生产者数据 //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} //#endregion } #region 插入窑车生产数据表 errMsg = AddKilnCarData(oracleTrConn, accountDate, kilnCarID, kilnCarBatchNo, workUserID, workUserCode, workUserName, Remarks, sUserInfo, maxClassesSettingID); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion //#region 窑车生产者 //// 查询新插入的生产数据ID //string sqlKilnCar = "select SEQ_PM_KilnCarData_ID.Currval from dual"; //string idKilnCar = oracleTrConn.GetSqlResultToStr(sqlKilnCar); //errMsg = AddKilnCarProducer(oracleTrConn, accountDate, Convert.ToInt32(idKilnCar), workUserID, sUserInfo); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} //#endregion } return errMsg; } catch (Exception ex) { throw ex; } } /// /// 校验窑车的工序与当前工序是否可以到达(重烧后,未走重烧入窑) /// /// 数据连接 /// 产品条码 /// string private static string GetKilnCarProcedureIDByKilnCarID(IDBTransaction oracleTrConn, int KilnCarID, int ProcedureID) { string sql = @"select ProcedureID from TP_PM_KilnCarStatus where KilnCarID=:KilnCarID"; OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":KilnCarID", KilnCarID) , }; int currentProcedureID = 0; DataSet result = oracleTrConn.GetSqlResultToDs(sql, paras); if (result != null && result.Tables[0].Rows.Count > 0) { currentProcedureID = Convert.ToInt32(result.Tables[0].Rows[0][0]); } sql = @"select pro.ProcedureID from TP_PC_ProcedureFlow flow inner join TP_PC_Procedure pro on flow.arriveprocedureid = pro.procedureid inner join TP_PC_ProductionLine line on pro.ProductionLineID = line.ProductionLineID where flow.ProcedureID = :currentProcedureID and flow.FlowFlag = 2"; paras = new OracleParameter[] { new OracleParameter(":currentProcedureID", currentProcedureID) , }; result = oracleTrConn.GetSqlResultToDs(sql, paras); int returnProcedureID = 0; if (result != null && result.Tables[0].Rows.Count > 0) { if (result.Tables[0].Select("ProcedureID=" + ProcedureID).Length > 0) { returnProcedureID = 1; } } // 保存失败 if (returnProcedureID == 0) { return string.Format("当前工序不允许进行操作", "条码", "保存"); } return null; } /// /// 出窑车计件 /// /// 数据连接对象 /// 工序对象 /// 条码信息 /// 用户基本信息 /// 返回的产品ID /// 返回的产品Code /// 返回的产品名称 /// string /// /// 张国印 2014.10.04 新建 /// private static string AddOutKilnCar(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo, out int goodsID, out string goodsCode, out string goodsName) { try { goodsID = Constant.INT_IS_ZERO; goodsCode = string.Empty; goodsName = string.Empty; string groutingUserCode = string.Empty; // 获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); string errMsg = string.Empty; // 生产工号 int workUserID = Constant.INT_IS_ZERO; // 生产工号Code string workUserCode = string.Empty; // 生产工号Name string workUserName = string.Empty; // 本批采集的批次号 string centralizedBatchNo = System.Guid.NewGuid().ToString(); // 窑车批次号 string kilnCarBatchNo = System.Guid.NewGuid().ToString(); // 窑车状态 string kilnCarStatus = string.Empty; ////////////////////////////////////////////////// DataView dv = barcodeTable.DefaultView; DataTable dtNewKiln = dv.ToTable(true, "kilnCarCode"); for (int i = 0; i < dtNewKiln.Rows.Count; i++) { // 窑车Code //string kilnCarCode = barcodeTable.Rows[0]["kilnCarCode"].ToString(); DataRow[] dr = barcodeTable.Select("kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'"); string kilnCarCode = dr[0]["kilnCarCode"].ToString(); string Remarks = dr[0]["Remarks"].ToString(); #region 校验窑车是否可出窑炉 errMsg = CheckKilnCarrStatus(oracleTrConn, procedure.ProcedureID, kilnCarCode, procedure.ModelType, sUserInfo, out kilnCarStatus); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion // 窑炉ID //int kilnID = Convert.ToInt32(barcodeTable.Rows[0]["kilnID"].ToString()); int kilnID = Convert.ToInt32(dr[0]["kilnID"].ToString()); // 窑车ID //int kilnCarID = Convert.ToInt32(barcodeTable.Rows[0]["KilnCarID"].ToString()); int kilnCarID = Convert.ToInt32(dr[0]["KilnCarID"].ToString()); // 主要目的防止输入窑车号,当前工序与该操作的工序不匹配,例如重烧入窑,在入窑工序上操作了 errMsg = GetKilnCarProcedureIDByKilnCarID(oracleTrConn, kilnCarID, Convert.ToInt32(procedure.ProcedureID)); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } // 查询本次窑车产品的批次号 kilnCarBatchNo = GetKilnCarBatchNoByKilnCarID(oracleTrConn, kilnCarID); #region 窑车表存在,查询本次窑车产品的批次号 并更改出窑车时间 //更改窑车状态表入窑时间 errMsg = UpdatekilnCarStatus(oracleTrConn, kilnCarID, Constant.ProcedureModelType.OutKiln, sUserInfo, procedure, kilnCarBatchNo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion //// 条码信息 DataView dvFilter = barcodeTable.DefaultView; dvFilter.RowFilter = "kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'"; DataTable dtNew = dvFilter.ToTable(); int? maxClassesSettingID = null; // 条码信息 //foreach (DataRow barcodeRow in barcodeTable.Rows) foreach (DataRow barcodeRow in dtNew.Rows) { // 条码 string barcode = barcodeRow["Barcode"].ToString(); // 生产工号 workUserID = Convert.ToInt32(barcodeRow["UserID"]); workUserCode = barcodeRow["UserCode"].ToString(); workUserName = barcodeRow["UserName"].ToString(); // 查询新插入的生产数据ID string sql = "select SEQ_PM_ProductionData_ID.nextval from dual"; string idStr = oracleTrConn.GetSqlResultToStr(sql); int productionDataID = 0; if (!string.IsNullOrEmpty(idStr)) { productionDataID = int.Parse(idStr); } else { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } int? ClassesSettingID = null;//班次配置ID #region 添加生产者数据 errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion maxClassesSettingID = ClassesSettingID; #region 添加生产数据 ProductionDataEntity productionData = new ProductionDataEntity(); #region 属性赋值 productionData.ClassesSettingID = ClassesSettingID; productionData.ProductionDataID = Convert.ToInt32(idStr); productionData.Barcode = barcode; productionData.CentralizedBatchNo = centralizedBatchNo; productionData.ProductionLineID = procedure.ProductionLineID; productionData.ProductionLineCode = procedure.ProductionlineCode; productionData.ProductionLineName = procedure.ProductionlineName; productionData.CompleteProcedureID = procedure.ProcedureID; productionData.ProcedureCode = procedure.ProcedureCode; productionData.ProcedureName = procedure.ProcedureName; productionData.ProcedureModel = procedure.ProcedureModel; productionData.ModelType = procedure.ModelType; productionData.NodeType = procedure.NodeType; productionData.DefectFlag = (int)Constant.DefectFlag.No; productionData.ReworkProcedureID = null; productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode); productionData.IsReFire = (int)Constant.ReFireFlag.No; productionData.PieceType = procedure.PieceType; //productionData.GoodsGrade = (int)Constant.GoodsGrade.Good; ////// string sqlReFire = @"select ////// isrefire ////// from tp_pm_inproduction where barcode=:barcode ////// "; ////// OracleParameter[] ReFireparas = new OracleParameter[] { ////// new OracleParameter(":barcode",barcode), ////// }; ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas); ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0) ////// { ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0) ////// { ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]); ////// } ////// } productionData.OrganizationID = procedure.OrganizationID; productionData.GoodsID = Convert.ToInt32(barcodeRow["GoodsID"]); productionData.GoodsCode = barcodeRow["GoodsCode"].ToString(); productionData.GoodsName = barcodeRow["GoodsName"].ToString(); productionData.UserID = workUserID; productionData.UserCode = barcodeRow["UserCode"].ToString(); productionData.UserName = barcodeRow["UserName"].ToString(); #region 窑炉窑车属性 productionData.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString()); productionData.KilnCode = barcodeRow["KilnCode"].ToString(); productionData.KilnName = barcodeRow["KilnName"].ToString(); productionData.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString()); productionData.KilnCarCode = barcodeRow["KilnCarCode"].ToString(); productionData.KilnCarName = barcodeRow["KilnCarName"].ToString(); productionData.KilnCarBatchNo = kilnCarBatchNo; productionData.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString()); productionData.Remarks = barcodeRow["Remarks"].ToString(); #endregion #endregion string OutSpecialRepairflag = "0";//干补标识 errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 修改在产产品数据的当前工序,清空返工工序字段 InProductionEntity addInProductionEntity = new InProductionEntity(); addInProductionEntity.BarCode = barcode; //流程工序 addInProductionEntity.FlowProcedureID = procedure.ProcedureID; // 当前工序 //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID; addInProductionEntity.ProcedureID = procedure.ProcedureID; // 生产数据ID addInProductionEntity.ProductionDataID = productionDataID; // 工序模型 addInProductionEntity.ProcedureModel = procedure.ProcedureModel; // 工序类别 addInProductionEntity.ModelType = procedure.ModelType; // 生产工号 addInProductionEntity.UserID = workUserID; // 缺陷标识 addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No; #region 更新在产表窑车窑炉字段 addInProductionEntity.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString()); addInProductionEntity.KilnCode = barcodeRow["KilnCode"].ToString(); addInProductionEntity.KilnName = barcodeRow["KilnName"].ToString(); addInProductionEntity.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString()); addInProductionEntity.KilnCarCode = barcodeRow["KilnCarCode"].ToString(); addInProductionEntity.KilnCarName = barcodeRow["KilnCarName"].ToString(); addInProductionEntity.KilnCarBatchNo = kilnCarBatchNo; addInProductionEntity.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString()); #endregion // 执行修改 errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion //#region 添加生产者数据 //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} //#endregion } #region 插入窑车生产数据表 errMsg = AddKilnCarData(oracleTrConn, accountDate, kilnCarID, kilnCarBatchNo, workUserID, workUserCode, workUserName, Remarks, sUserInfo, maxClassesSettingID); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion //#region 窑车生产者 //// 查询新插入的生产数据ID //string sqlKilnCar = "select SEQ_PM_KilnCarData_ID.Currval from dual"; //string idKilnCar = oracleTrConn.GetSqlResultToStr(sqlKilnCar); //errMsg = AddKilnCarProducer(oracleTrConn, accountDate, Convert.ToInt32(idKilnCar), workUserID, sUserInfo); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} //#endregion } return errMsg; } catch (Exception ex) { throw ex; } } /// /// 卸窑车计件 /// /// 数据连接对象 /// 工序对象 /// 条码信息 /// 用户基本信息 /// 返回的产品ID /// 返回的产品Code /// 返回的产品名称 /// string /// /// 张国印 2014.10.04 新建 /// private static string AddUnloadingKilnCar(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo, out int goodsID, out string goodsCode, out string goodsName) { try { goodsID = Constant.INT_IS_ZERO; goodsCode = string.Empty; goodsName = string.Empty; string groutingUserCode = string.Empty; // 获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); string errMsg = string.Empty; // 生产工号 int workUserID = Constant.INT_IS_ZERO; // 生产工号Code string workUserCode = string.Empty; // 生产工号Name string workUserName = string.Empty; // 本批采集的批次号 string centralizedBatchNo = System.Guid.NewGuid().ToString(); string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo; // 窑车批次号 string kilnCarBatchNo = null;//System.Guid.NewGuid().ToString(); // 窑车状态 string kilnCarStatus = string.Empty; DataView dv = barcodeTable.DefaultView; DataTable dtNewKiln = dv.ToTable(true, "kilnCarCode"); for (int i = 0; i < dtNewKiln.Rows.Count; i++) { // 窑车Code //string kilnCarCode = barcodeTable.Rows[0]["kilnCarCode"].ToString(); DataRow[] dr = barcodeTable.Select("kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'"); string kilnCarCode = dr[0]["kilnCarCode"].ToString(); string Remarks = dr[0]["Remarks"].ToString(); #region 校验窑车是否可出窑炉 errMsg = CheckKilnCarrStatus(oracleTrConn, procedure.ProcedureID, kilnCarCode, procedure.ModelType, sUserInfo, out kilnCarStatus); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion // 窑炉ID //int kilnID = Convert.ToInt32(barcodeTable.Rows[0]["kilnID"].ToString()); int kilnID = Convert.ToInt32(dr[0]["kilnID"].ToString()); // 窑车ID //int kilnCarID = Convert.ToInt32(barcodeTable.Rows[0]["KilnCarID"].ToString()); int kilnCarID = Convert.ToInt32(dr[0]["KilnCarID"].ToString()); // 主要目的防止输入窑车号,当前工序与该操作的工序不匹配,例如重烧入窑,在入窑工序上操作了 errMsg = GetKilnCarProcedureIDByKilnCarID(oracleTrConn, kilnCarID, Convert.ToInt32(procedure.ProcedureID)); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } // 查询本次窑车产品的批次号 kilnCarBatchNo = GetKilnCarBatchNoByKilnCarID(oracleTrConn, kilnCarID); #region 窑车表存在,查询本次窑车产品的批次号 并更改出窑车时间 //更改窑车状态表入窑时间 errMsg = UpdatekilnCarStatus(oracleTrConn, kilnCarID, Constant.ProcedureModelType.UnloadCar, sUserInfo, procedure, kilnCarBatchNo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion // 条码信息 DataView dvFilter = barcodeTable.DefaultView; dvFilter.RowFilter = "kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'"; DataTable dtNew = dvFilter.ToTable(); int? maxClassesSettingID = null; // 条码信息 //foreach (DataRow barcodeRow in barcodeTable.Rows) foreach (DataRow barcodeRow in dtNew.Rows) { // 条码 string barcode = barcodeRow["Barcode"].ToString(); // 生产工号 workUserID = Convert.ToInt32(barcodeRow["UserID"]); workUserCode = barcodeRow["UserCode"].ToString(); workUserName = barcodeRow["UserName"].ToString(); // 查询新插入的生产数据ID string sql = "select SEQ_PM_ProductionData_ID.nextval from dual"; string idStr = oracleTrConn.GetSqlResultToStr(sql); int productionDataID = 0; if (!string.IsNullOrEmpty(idStr)) { productionDataID = int.Parse(idStr); } else { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } int? ClassesSettingID = null;//班次配置ID #region 添加生产者数据 errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion maxClassesSettingID = ClassesSettingID; #region 添加生产数据 ProductionDataEntity productionData = new ProductionDataEntity(); #region 属性赋值 productionData.ClassesSettingID = ClassesSettingID; productionData.ProductionDataID = Convert.ToInt32(idStr); productionData.Barcode = barcode; productionData.CentralizedBatchNo = centralizedBatchNo; productionData.ProductionLineID = procedure.ProductionLineID; productionData.ProductionLineCode = procedure.ProductionlineCode; productionData.ProductionLineName = procedure.ProductionlineName; productionData.CompleteProcedureID = procedure.ProcedureID; productionData.ProcedureCode = procedure.ProcedureCode; productionData.ProcedureName = procedure.ProcedureName; productionData.ProcedureModel = procedure.ProcedureModel; productionData.ModelType = procedure.ModelType; productionData.NodeType = procedure.NodeType; productionData.DefectFlag = (int)Constant.DefectFlag.No; productionData.ReworkProcedureID = null; productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode); productionData.IsReFire = (int)Constant.ReFireFlag.No; productionData.GoodsGrade = (int)Constant.GoodsGrade.Good; productionData.PieceType = procedure.PieceType; ////// string sqlReFire = @"select ////// isrefire ////// from tp_pm_inproduction where barcode=:barcode ////// "; ////// OracleParameter[] ReFireparas = new OracleParameter[] { ////// new OracleParameter(":barcode",barcode), ////// }; ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas); ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0) ////// { ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0) ////// { ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]); ////// } ////// } productionData.OrganizationID = procedure.OrganizationID; productionData.GoodsID = Convert.ToInt32(barcodeRow["GoodsID"]); productionData.GoodsCode = barcodeRow["GoodsCode"].ToString(); productionData.GoodsName = barcodeRow["GoodsName"].ToString(); productionData.UserID = workUserID; productionData.UserCode = barcodeRow["UserCode"].ToString(); productionData.UserName = barcodeRow["UserName"].ToString(); #region 窑炉窑车属性 productionData.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString()); productionData.KilnCode = barcodeRow["KilnCode"].ToString(); productionData.KilnName = barcodeRow["KilnName"].ToString(); productionData.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString()); productionData.KilnCarCode = barcodeRow["KilnCarCode"].ToString(); productionData.KilnCarName = barcodeRow["KilnCarName"].ToString(); productionData.KilnCarBatchNo = kilnCarBatchNo; productionData.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString()); productionData.Remarks = barcodeRow["Remarks"].ToString(); #endregion #endregion string OutSpecialRepairflag = "0";//干补标识 errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion if (procedure.NodeType == Constant.ProcedureNodeType.Middle.GetHashCode()) { #region 中间工序 修改在产产品数据的当前工序,清空返工工序字段 InProductionEntity addInProductionEntity = new InProductionEntity(); addInProductionEntity.BarCode = barcode; //流程工序ID addInProductionEntity.FlowProcedureID = procedure.ProcedureID; // 当前工序 addInProductionEntity.ProcedureID = procedure.ProcedureID; // 生产数据ID addInProductionEntity.ProductionDataID = productionDataID; // 工序模型 addInProductionEntity.ProcedureModel = procedure.ProcedureModel; // 工序类别 addInProductionEntity.ModelType = procedure.ModelType; // 生产工号 addInProductionEntity.UserID = workUserID; // 缺陷标识 addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No; #region 更新在产表窑车窑炉字段 addInProductionEntity.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString()); addInProductionEntity.KilnCode = barcodeRow["KilnCode"].ToString(); addInProductionEntity.KilnName = barcodeRow["KilnName"].ToString(); addInProductionEntity.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString()); addInProductionEntity.KilnCarCode = barcodeRow["KilnCarCode"].ToString(); addInProductionEntity.KilnCarName = barcodeRow["KilnCarName"].ToString(); addInProductionEntity.KilnCarBatchNo = kilnCarBatchNo; addInProductionEntity.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString()); #endregion // 执行修改 errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } else if (procedure.NodeType == Constant.ProcedureNodeType.End.GetHashCode()) { #region 结束工序 添加成品数据 删除在产产品数据 FinishedProductEntity finishedProduct = new FinishedProductEntity(); finishedProduct.BarCode = barcode; errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } InProductionEntity delInProductionEntity = new InProductionEntity(); delInProductionEntity.BarCode = barcode; // 执行删除 在产数据 errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } //#region 添加生产者数据 //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} //#endregion } #region 插入窑车生产数据表 errMsg = AddKilnCarData(oracleTrConn, accountDate, kilnCarID, kilnCarBatchNo, workUserID, workUserCode, workUserName, Remarks, sUserInfo, maxClassesSettingID); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion //#region 窑车生产者 //// 查询新插入的生产数据ID //string sqlKilnCar = "select SEQ_PM_KilnCarData_ID.Currval from dual"; //string idKilnCar = oracleTrConn.GetSqlResultToStr(sqlKilnCar); //errMsg = AddKilnCarProducer(oracleTrConn, accountDate, Convert.ToInt32(idKilnCar), workUserID, sUserInfo); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} //#endregion #region 删除TP_PM_KilnCarGoods数据 按照窑车ID errMsg = DeleteKilnCarGoodsByKilnCarID(oracleTrConn, kilnCarID); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } return errMsg; } catch (Exception ex) { throw ex; } } /// /// 窑车补件计件 /// /// 数据连接对象 /// 工序对象 /// 条码信息 /// 用户基本信息 /// 返回的产品ID /// 返回的产品Code /// 返回的产品名称 /// string /// /// 张国印 2014.10.05 新建 /// private static string AddKilnCarSupplement(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo, out int goodsID, out string goodsCode, out string goodsName) { try { goodsID = Constant.INT_IS_ZERO; goodsCode = null; goodsName = null; string groutingUserCode = string.Empty; // 获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); string errMsg = ""; // 生产工号 int workUserID = Constant.INT_IS_ZERO; // 生产工号Code string workUserCode = string.Empty; // 生产工号Name string workUserName = string.Empty; // 本批采集的批次号 string centralizedBatchNo = System.Guid.NewGuid().ToString(); // 窑车Code string kilnCarCode = barcodeTable.Rows[0]["kilnCarCode"].ToString(); // 窑车批次号 string kilnCarBatchNo = System.Guid.NewGuid().ToString(); // 窑车状态 string kilnCarStatus = string.Empty; #region 校验窑车是否可装车 errMsg = CheckKilnCarrStatus(oracleTrConn, procedure.ProcedureID, kilnCarCode, procedure.ModelType, sUserInfo, out kilnCarStatus); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion // 窑炉ID //int kilnID = Convert.ToInt32(barcodeTable.Rows[0]["kilnID"].ToString()); //// 窑车ID //int kilnCarID = Convert.ToInt32(barcodeTable.Rows[0]["KilnCarID"].ToString()); int kilnID = 0; // 窑车ID int kilnCarID = 0; // 条码信息 foreach (DataRow barcodeRow in barcodeTable.Rows) { kilnID = Convert.ToInt32(barcodeRow["kilnID"]); kilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString()); //窑车表存在,查询本次窑车产品的批次号 并更改装窑车时间 kilnCarBatchNo = GetKilnCarBatchNoByKilnCarID(oracleTrConn, kilnCarID); // 条码 string barcode = barcodeRow["Barcode"].ToString(); // 生产工号 workUserID = Convert.ToInt32(barcodeRow["UserID"]); workUserCode = barcodeRow["UserCode"].ToString(); workUserName = barcodeRow["UserName"].ToString(); //#region 校验条码有效性 //errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} //#endregion if (procedure.CollectType == 1) { #region 校验条码有效性 errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } else { string sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid, tp_pm_groutingdailydetail.goodscode, tp_pm_groutingdailydetail.goodsname, tp_pm_groutingdailydetail.usercode as groutingUserCode from tp_pm_groutingdailydetail where barcode=:barcode "; OracleParameter[] ReFireparas = new OracleParameter[] { new OracleParameter(":barcode",barcode), }; DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, ReFireparas); if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0) { goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]); goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString(); goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString(); groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString(); } } // 查询新插入的生产数据ID string sql = "select SEQ_PM_ProductionData_ID.nextval from dual"; string idStr = oracleTrConn.GetSqlResultToStr(sql); int productionDataID = 0; if (!string.IsNullOrEmpty(idStr)) { productionDataID = int.Parse(idStr); } else { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } int? ClassesSettingID = null;//班次配置ID #region 添加生产者数据 errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 添加生产数据 ProductionDataEntity productionData = new ProductionDataEntity(); #region 属性赋值 productionData.ClassesSettingID = ClassesSettingID; productionData.ProductionDataID = Convert.ToInt32(idStr); productionData.Barcode = barcode; productionData.CentralizedBatchNo = centralizedBatchNo; productionData.ProductionLineID = procedure.ProductionLineID; productionData.ProductionLineCode = procedure.ProductionlineCode; productionData.ProductionLineName = procedure.ProductionlineName; productionData.CompleteProcedureID = procedure.ProcedureID; productionData.ProcedureCode = procedure.ProcedureCode; productionData.ProcedureName = procedure.ProcedureName; productionData.ProcedureModel = procedure.ProcedureModel; productionData.ModelType = procedure.ModelType; productionData.NodeType = procedure.NodeType; productionData.DefectFlag = (int)Constant.DefectFlag.No; productionData.ReworkProcedureID = null; productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode); productionData.IsReFire = (int)Constant.ReFireFlag.No; productionData.GoodsGrade = (int)Constant.GoodsGrade.Good; productionData.OrganizationID = procedure.OrganizationID; productionData.GoodsID = goodsID; productionData.GoodsCode = goodsCode; productionData.GoodsName = goodsName; productionData.UserID = workUserID; productionData.UserCode = barcodeRow["UserCode"].ToString(); productionData.UserName = barcodeRow["UserName"].ToString(); productionData.PieceType = procedure.PieceType; #region 窑炉窑车属性 productionData.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString()); productionData.KilnCode = barcodeRow["KilnCode"].ToString(); productionData.KilnName = barcodeRow["KilnName"].ToString(); productionData.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString()); productionData.KilnCarCode = barcodeRow["KilnCarCode"].ToString(); productionData.KilnCarName = barcodeRow["KilnCarName"].ToString(); productionData.KilnCarBatchNo = kilnCarBatchNo; productionData.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString()); #endregion #endregion string OutSpecialRepairflag = "0";//干补标识 errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 修改在产产品数据的当前工序,清空返工工序字段 InProductionEntity addInProductionEntity = new InProductionEntity(); addInProductionEntity.BarCode = barcode; //流程工序 addInProductionEntity.FlowProcedureID = procedure.ProcedureID; // 当前工序 //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID; addInProductionEntity.ProcedureID = procedure.ProcedureID; //生产数据ID addInProductionEntity.ProductionDataID = productionDataID; // 工序模型 addInProductionEntity.ProcedureModel = procedure.ProcedureModel; // 工序类别 addInProductionEntity.ModelType = procedure.ModelType; // 生产工号 addInProductionEntity.UserID = workUserID; // 缺陷标识 addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No; #region 更新在产表窑车窑炉字段 addInProductionEntity.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString()); addInProductionEntity.KilnCode = barcodeRow["KilnCode"].ToString(); addInProductionEntity.KilnName = barcodeRow["KilnName"].ToString(); addInProductionEntity.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString()); addInProductionEntity.KilnCarCode = barcodeRow["KilnCarCode"].ToString(); addInProductionEntity.KilnCarName = barcodeRow["KilnCarName"].ToString(); addInProductionEntity.KilnCarBatchNo = kilnCarBatchNo; addInProductionEntity.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString()); #endregion // 执行修改 errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion //#region 添加生产者数据 //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} //#endregion #region 插入窑车产品表 errMsg = AddKilnCarGoods(oracleTrConn, barcode, kilnCarID, goodsID, productionData.KilnCarPosition.Value, kilnCarBatchNo, workUserID, workUserCode, workUserName, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } return errMsg; } catch (Exception ex) { throw ex; } } /// /// 插入窑车生产数据表(装车) /// /// 连接对象 /// 账务日期 /// 窑车ID /// 窑车批次号 /// 生产工号ID /// 生产工号Code /// 生产工号Name /// 用户基本信息 /// string private static string AddKilnCarDataCreateTime(IDBTransaction oracleTrConn, DateTime accountDate, int kilnCarID, string kilnCarBatchNo, int workUserID, string workUserCode, string workUserName, string remarks, DateTime? createtime, SUserInfo sUserInfo) { #region SQL string sql = "insert into tp_pm_kilncardata" + " (kilncarbatchno," + " kilncarid," + " kilnid," + " productionlineid," + " procedureid," + " procedurecode," + " procedurename," + " proceduremodel," + " modeltype," + " piecetype," + " kilncarstatus," + " UserID," + " UserCode," + " UserName," + " loadingtime," + " intokilntime," + " outkilntime," + " unloadingtime," + " accountdate," + " accountid," + " createuserid," + " updateuserid," + " createtime," + " remarks)" + " select " + " :pkilncarbatchno," + " kilncarid," + " kilnid," + " productionlineid," + " procedureid," + " procedurecode," + " procedurename," + " proceduremodel," + " modeltype," + " piecetype," + " kilncarstatus," + " :puserID," + " :puserCode," + " :puserName," + " loadingtime," + " intokilntime," + " outkilntime," + " unloadingtime," + " :paccountdate," + " :paccountid," + " :pcreateuserid," + " :pupdateuserid," + " :createtime," + " :remarks" + " from tp_pm_kilncarstatus" + " where kilncarid = :pkilncarid"; #endregion #region 参数 OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":pkilncarbatchno",OracleDbType.Varchar2,kilnCarBatchNo,ParameterDirection.Input), new OracleParameter(":puserID",OracleDbType.Int32,workUserID,ParameterDirection.Input), new OracleParameter(":puserCode",OracleDbType.Varchar2,workUserCode,ParameterDirection.Input), new OracleParameter(":puserName",OracleDbType.Varchar2,workUserName,ParameterDirection.Input), new OracleParameter(":paccountdate",OracleDbType.Date,accountDate,ParameterDirection.Input), new OracleParameter(":paccountid",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input), new OracleParameter(":pcreateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":pupdateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":pkilncarid",OracleDbType.Int32,kilnCarID,ParameterDirection.Input), new OracleParameter(":remarks",OracleDbType.Varchar2,remarks,ParameterDirection.Input), new OracleParameter(":createtime",OracleDbType.Date,Convert.ToDateTime(createtime),ParameterDirection.Input), }; #endregion int result = oracleTrConn.ExecuteNonQuery(sql, paras); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 保存成功返回null return null; } /// /// 插入窑车生产数据表 /// /// 连接对象 /// 账务日期 /// 窑车ID /// 窑车批次号 /// 生产工号ID /// 生产工号Code /// 生产工号Name /// 用户基本信息 /// string private static string AddKilnCarData(IDBTransaction oracleTrConn, DateTime accountDate, int kilnCarID, string kilnCarBatchNo, int workUserID, string workUserCode, string workUserName, string remarks, SUserInfo sUserInfo, int? ClassesSettingID) { #region SQL string sql = "insert into tp_pm_kilncardata" + " (kilncarbatchno," + " kilncarid," + " kilnid," + " productionlineid," + " procedureid," + " procedurecode," + " procedurename," + " proceduremodel," + " modeltype," + " piecetype," + " kilncarstatus," + " UserID," + " UserCode," + " UserName," + " loadingtime," + " intokilntime," + " outkilntime," + " unloadingtime," + " accountdate," + " accountid," + " createuserid," + " updateuserid," + " classesSettingID," + " remarks)" + " select " + " :pkilncarbatchno," + " kilncarid," + " kilnid," + " productionlineid," + " procedureid," + " procedurecode," + " procedurename," + " proceduremodel," + " modeltype," + " piecetype," + " kilncarstatus," + " :puserID," + " :puserCode," + " :puserName," + " loadingtime," + " intokilntime," + " outkilntime," + " unloadingtime," + " :paccountdate," + " :paccountid," + " :pcreateuserid," + " :pupdateuserid," + " :classesSettingID," + " :remarks" + " from tp_pm_kilncarstatus" + " where kilncarid = :pkilncarid"; #endregion #region 参数 OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":classesSettingID",OracleDbType.Int32,ClassesSettingID,ParameterDirection.Input), new OracleParameter(":pkilncarbatchno",OracleDbType.Varchar2,kilnCarBatchNo,ParameterDirection.Input), new OracleParameter(":puserID",OracleDbType.Int32,workUserID,ParameterDirection.Input), new OracleParameter(":puserCode",OracleDbType.Varchar2,workUserCode,ParameterDirection.Input), new OracleParameter(":puserName",OracleDbType.Varchar2,workUserName,ParameterDirection.Input), new OracleParameter(":paccountdate",OracleDbType.Date,accountDate,ParameterDirection.Input), new OracleParameter(":paccountid",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input), new OracleParameter(":pcreateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":pupdateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":pkilncarid",OracleDbType.Int32,kilnCarID,ParameterDirection.Input), new OracleParameter(":remarks",OracleDbType.Varchar2,remarks,ParameterDirection.Input), }; #endregion int result = oracleTrConn.ExecuteNonQuery(sql, paras); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 保存成功返回null return null; } /// /// 插入窑车产品表 /// /// 连接对象 /// 条码 /// 窑车号 /// 产品ID /// 窑车位置 /// 装车批次 /// 用户基本信息 /// string private static string AddKilnCarGoods(IDBTransaction oracleTrConn, string barcode, int kilnCarID, int goodsID, int KilnCarPosition, string kilnCarBatchNo, int workUserID, string workUserCode, string workUserName, SUserInfo sUserInfo) { string sqlExist = "select 1 from tp_pm_kilncargoods where barcode=:barcode and accountid=:accountid"; OracleParameter[] parasExist = new OracleParameter[] { new OracleParameter(":barcode",barcode), new OracleParameter(":accountid",sUserInfo.AccountID), }; oracleTrConn.ExecuteNonQuery(sqlExist, parasExist); DataSet dsExist = oracleTrConn.GetSqlResultToDs(sqlExist, parasExist); if (dsExist != null && dsExist.Tables[0].Rows.Count == 0) { string sql = "insert into tp_pm_kilncargoods" + " (barcode," + " kilncarid," + " goodsid," + " kilncarposition," + " kilncarbatchno," + " accountid," + " userid," + " usercode," + " username," + " createuserid," + " updateuserid)" + " values" + " (:barcode," + " :kilncarid," + " :goodsid," + " :kilncarposition," + " :kilncarbatchno," + " :accountid," + " :userid," + " :usercode," + " :username," + " :createuserid," + " :updateuserid)"; #region 参数 OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":barcode",barcode), new OracleParameter(":kilncarid",kilnCarID), new OracleParameter(":goodsid",goodsID), new OracleParameter(":kilncarposition",KilnCarPosition), new OracleParameter(":kilncarbatchno",kilnCarBatchNo), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":userid",workUserID), new OracleParameter(":usercode",workUserCode), new OracleParameter(":username",workUserName), }; #endregion int result = oracleTrConn.ExecuteNonQuery(sql, paras); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } } // 保存成功返回null return null; } /// /// 查询本次批次号 /// /// 连接对象 /// 窑车ID /// string private static string GetKilnCarBatchNoByKilnCarID(IDBTransaction oracleTrConn, int kilnCarID) { string sql = "SELECT Max(KilnCarBatchNo) FROM TP_PM_KilnCarGoods where KilnCarID = :kilnCarID"; #region 参数 OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":kilnCarID",kilnCarID), }; #endregion string batchNo = oracleTrConn.GetSqlResultToStr(sql, paras); if (!string.IsNullOrEmpty(batchNo)) { return batchNo; } else { return System.Guid.NewGuid().ToString(); } } /// /// 插入窑车状态表 /// /// 连接对象 /// 工序ID /// 窑车ID /// 窑炉ID /// 用户基本信息 /// string private static string AddkilnCarStatus(IDBTransaction oracleTrConn, ProcedureEntity procedure, int kilnCarID, int kilnID, string kilnCarBatchNo, SUserInfo sUserInfo) { #region SQL string sql = " insert into tp_pm_kilncarstatus " + " (kilncarid, " + " kilnid, " + " productionlineid, " + " procedureid, " + " procedurecode, " + " procedurename, " + " proceduremodel, " + " modeltype, " + " piecetype, " + " kilncarstatus, " + " loadingtime, " + " accountid, " + " createuserid, " + " updateuserid,kilnCarBatchNo) " + " values " + " (:kilncarid, " + " :kilnid, " + " :productionlineid, " + " :procedureid, " + " :procedurecode, " + " :procedurename, " + " :proceduremodel, " + " :modeltype, " + " :piecetype, " + " '0', " + " sysdate, " + " :accountid, " + " :createuserid, " + " :updateuserid,:kilnCarBatchNo)"; #endregion #region 参数 OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":kilncarid",kilnCarID), new OracleParameter(":kilnid",kilnID), new OracleParameter(":productionlineid",procedure.ProductionLineID), new OracleParameter(":procedureid",procedure.ProcedureID), new OracleParameter(":procedurecode",procedure.ProcedureCode), new OracleParameter(":procedurename",procedure.ProcedureName), new OracleParameter(":proceduremodel",procedure.ProcedureModel), new OracleParameter(":modeltype",procedure.ModelType), new OracleParameter(":piecetype",procedure.PieceType), new OracleParameter(":accountID",sUserInfo.AccountID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":kilnCarBatchNo",kilnCarBatchNo), }; #endregion int result = oracleTrConn.ExecuteNonQuery(sql, paras); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 保存成功返回null return null; } /// /// 更新窑车状态表中的对应的时间 /// /// 数据连接 /// 窑车ID /// 操作类型 /// 用户基本信息 /// /// 张国印 2014.10.04 新建 /// private static string UpdatekilnCarStatus(IDBTransaction oracleTrConn, int kilnCarID, Constant.ProcedureModelType pModelType, SUserInfo sUserInfo, ProcedureEntity procedure, string kilnCarBatchNo) { if (pModelType == Constant.ProcedureModelType.LoadCar) { //procedure.ProcedureID, //procedure.ProcedureCode, //procedure.ProcedureName, //procedure.ModelType #region 装窑车操作时,更新tp_pm_kilncarstatus的装车时间 #region SQL语句和参数 string sql = " Update tp_pm_kilncarstatus Set" + " KilnCarStatus = :pKilnCarStatus, " + " LoadingTime = sysdate, " + " IntoKilnTime = null, " + " OutKilnTime = null, " + " UnloadingTime = null, " + " UpdateUserID = :pUpdateUserID, " + " ProcedureID = :ProcedureID, " + " ProcedureCode = :ProcedureCode, " + " ProcedureName = :ProcedureName, " + " ModelType = :ModelType, " + " kilnCarBatchNo = :kilnCarBatchNo " + " Where KilnCarID = :pKilnCarID And AccountID = :pAccountID"; OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":pKilnCarStatus", OracleDbType.Int32, 0, ParameterDirection.Input), new OracleParameter(":pUpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input), new OracleParameter(":pKilnCarID", OracleDbType.Int32, kilnCarID, ParameterDirection.Input), new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input), new OracleParameter(":ProcedureID", OracleDbType.Int32, procedure.ProcedureID, ParameterDirection.Input), new OracleParameter(":ProcedureCode", OracleDbType.Varchar2, procedure.ProcedureCode, ParameterDirection.Input), new OracleParameter(":ProcedureName", OracleDbType.Varchar2, procedure.ProcedureName, ParameterDirection.Input), new OracleParameter(":ModelType", OracleDbType.Int32, procedure.ModelType, ParameterDirection.Input), new OracleParameter(":kilnCarBatchNo", OracleDbType.Varchar2, kilnCarBatchNo, ParameterDirection.Input), }; #endregion int result = oracleTrConn.ExecuteNonQuery(sql, paras); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "窑车状态", "保存"); } #endregion } else if (pModelType == Constant.ProcedureModelType.IntoKiln) { #region 入窑操作时,更新tp_pm_kilncarstatus的入窑时间 #region SQL语句和参数 string sql = " Update tp_pm_kilncarstatus Set" + " KilnCarStatus = :pKilnCarStatus, " + " IntoKilnTime = sysdate, " + " UpdateUserID = :pUpdateUserID, " + " ProcedureID = :ProcedureID, " + " ProcedureCode = :ProcedureCode, " + " ProcedureName = :ProcedureName, " + " ModelType = :ModelType " + " Where KilnCarID = :pKilnCarID And AccountID = :pAccountID"; OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":pKilnCarStatus", OracleDbType.Int32, 1, ParameterDirection.Input), new OracleParameter(":pUpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input), new OracleParameter(":pKilnCarID", OracleDbType.Int32, kilnCarID, ParameterDirection.Input), new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input), new OracleParameter(":ProcedureID", OracleDbType.Int32, procedure.ProcedureID, ParameterDirection.Input), new OracleParameter(":ProcedureCode", OracleDbType.Varchar2, procedure.ProcedureCode, ParameterDirection.Input), new OracleParameter(":ProcedureName", OracleDbType.Varchar2, procedure.ProcedureName, ParameterDirection.Input), new OracleParameter(":ModelType", OracleDbType.Int32, procedure.ModelType, ParameterDirection.Input), }; #endregion int result = oracleTrConn.ExecuteNonQuery(sql, paras); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "窑车状态", "保存"); } #endregion } else if (pModelType == Constant.ProcedureModelType.OutKiln) { #region 出窑操作时,更新tp_pm_kilncarstatus的出窑时间 #region SQL语句和参数 string sql = " Update tp_pm_kilncarstatus Set" + " OutKilnTime = sysdate, " + " UpdateUserID = :pUpdateUserID, " + " ProcedureID = :ProcedureID, " + " ProcedureCode = :ProcedureCode, " + " ProcedureName = :ProcedureName, " + " ModelType = :ModelType " + " Where KilnCarID = :pKilnCarID And AccountID = :pAccountID"; OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":pUpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input), new OracleParameter(":pKilnCarID", OracleDbType.Int32, kilnCarID, ParameterDirection.Input), new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input), new OracleParameter(":ProcedureID", OracleDbType.Int32, procedure.ProcedureID, ParameterDirection.Input), new OracleParameter(":ProcedureCode", OracleDbType.Varchar2, procedure.ProcedureCode, ParameterDirection.Input), new OracleParameter(":ProcedureName", OracleDbType.Varchar2, procedure.ProcedureName, ParameterDirection.Input), new OracleParameter(":ModelType", OracleDbType.Int32, procedure.ModelType, ParameterDirection.Input), }; #endregion int result = oracleTrConn.ExecuteNonQuery(sql, paras); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "窑车状态", "保存"); } #endregion } else if (pModelType == Constant.ProcedureModelType.UnloadCar) { #region 卸窑车操作时,更新tp_pm_kilncarstatus的卸窑车时间 #region SQL语句和参数 string sql = " Update tp_pm_kilncarstatus Set" + " KilnCarStatus = :pKilnCarStatus, " //+ " LoadingTime = null, " //+ " IntoKilnTime = null, " //+ " OutKilnTime = null, " + " UnloadingTime = sysdate, " + " UpdateUserID = :pUpdateUserID, " + " ProcedureID = :ProcedureID, " + " ProcedureCode = :ProcedureCode, " + " ProcedureName = :ProcedureName, " + " ModelType = :ModelType " + " Where KilnCarID = :pKilnCarID And AccountID = :pAccountID"; OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":pKilnCarStatus", OracleDbType.Int32, 0, ParameterDirection.Input), new OracleParameter(":pUpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input), new OracleParameter(":pKilnCarID", OracleDbType.Int32, kilnCarID, ParameterDirection.Input), new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input), new OracleParameter(":ProcedureID", OracleDbType.Int32, procedure.ProcedureID, ParameterDirection.Input), new OracleParameter(":ProcedureCode", OracleDbType.Varchar2, procedure.ProcedureCode, ParameterDirection.Input), new OracleParameter(":ProcedureName", OracleDbType.Varchar2, procedure.ProcedureName, ParameterDirection.Input), new OracleParameter(":ModelType", OracleDbType.Int32, procedure.ModelType, ParameterDirection.Input), }; #endregion int result = oracleTrConn.ExecuteNonQuery(sql, paras); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "窑车状态", "保存"); } #endregion } // 保存成功返回null return string.Empty; } /// /// 校验窑车是否可用 /// /// 连接对象 /// 工序ID /// 窑车号 /// 操作类型 /// 用户基本信息 /// 窑车状态 /// string private static string CheckKilnCarrStatus(IDBTransaction oracleTrConn, int pProcedureId, string kilnCarCode, int pModelType, SUserInfo sUserInfo, out string kilnCarStatus) { kilnCarStatus = string.Empty; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter("in_accountID",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input), new OracleParameter("in_kilnCarCode",OracleDbType.NVarchar2, kilnCarCode,ParameterDirection.Input), new OracleParameter("in_modelType",OracleDbType.Int32, pModelType,ParameterDirection.Input), new OracleParameter("out_errMsg",OracleDbType.NVarchar2,2000,null,ParameterDirection.Output), new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output), new OracleParameter("in_procedureid",OracleDbType.Int32, pProcedureId,ParameterDirection.Input), // 验证能否卸窑 new OracleParameter("in_UserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), }; DataSet returnDataSet = oracleTrConn.ExecStoredProcedure("PRO_PM_CheckKilnCar", paras); string errMsg = paras[3].Value.ToString() == "null" ? string.Empty : paras[3].Value.ToString(); if (string.IsNullOrEmpty(errMsg)) { if (pModelType == (int)Constant.ProcedureModelType.LoadCar) { kilnCarStatus = returnDataSet.Tables[0].Rows[0]["KilnCarStatus"].ToString(); } } return errMsg; } /// /// 添加生产者 /// /// 连接对象 /// 账务日期 /// 生产数据ID /// 生产工号ID /// 生产工号Code /// 用户基本信息 /// string private static string AddProducer(IDBTransaction oracleTrConn, DateTime accountDate, int productionDataID, int workUserID, string workUserCode, SUserInfo sUserInfo, ref int? ClassesSettingID) { // 参数 OracleParameter[] paras; #region 查询班次配置表是否有数据 string sql = "select max(ClassesSettingID)" + " from tp_pc_classessetting" + " where Valueflag =1 and AccountID = :accountID" + " and UserID = :userID" + " and AccountDate = :accountDate"; paras = new OracleParameter[] { new OracleParameter(":accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input), new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input), new OracleParameter(":accountDate",OracleDbType.Date,accountDate,ParameterDirection.Input), }; string countStr = oracleTrConn.GetSqlResultToStr(sql, paras); int classesSettingID = 0; #endregion #region 没有班次配置数据,将工号所属员工插入班次配置表中 if (string.IsNullOrEmpty(countStr) || Constant.INT_IS_ZERO == int.Parse(countStr)) { // 查询新插入的班次配置表ID sql = "select SEQ_PC_ClassesSetting_ID.nextval from dual"; string idStr = oracleTrConn.GetSqlResultToStr(sql); // 新插入的班次配置表ID if (!string.IsNullOrEmpty(idStr)) { classesSettingID = int.Parse(idStr); } else { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } ClassesSettingID = Convert.ToInt32(classesSettingID); #region 班次配置总表 sql = "insert into tp_pc_classessetting" + " (ClassesSettingID,accountdate, " + " userid, " + " usercode, " + " accountid, " + " createuserid, " + " updateuserid,ORGANIZATIONID)" + " select " + " :classesSettingID, " + " :accountdate, " + " USERID, " + " UserCode, " + " accountid," + " :createuserid," + " :updateuserid,ORGANIZATIONID" + " from TP_MST_User" + " where UserID = :userID"; paras = new OracleParameter[] { new OracleParameter(":classesSettingID",OracleDbType.Int32,classesSettingID,ParameterDirection.Input), new OracleParameter(":accountDate",OracleDbType.Date,accountDate,ParameterDirection.Input), new OracleParameter(":createuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":updateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input), }; int result = oracleTrConn.ExecuteNonQuery(sql, paras); // 失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } #endregion #region 班次配置明细SQL sql = " insert into tp_pc_classesdetail" + " (classessettingid," + " accountdate," + " userid," + " usercode," + " UJobsID," + " staffid," + " SJobsID," + " staffstatus," + " accountid," + " createuserid," + " updateuserid,Uorganizationid,Sorganizationid)" + " select " + " :classessettingid," + " :accountdate," + " userStaff.Userid," + " :usercode," + " userStaff.Ujobsid," + " userStaff.Staffid," + " staff.Jobs," + " staff.staffstatus," + " :accountID," + " :createuserid," + " :updateuserid,user2.organizationid,staff.organizationid" + " from TP_MST_UserStaff userStaff" + " inner join tp_hr_staff staff on staff.staffid = userStaff.Staffid" + " inner join tp_mst_user user2 on userStaff.userid = user2.userid" + " where (staff.StaffStatus = 1 or staff.StaffStatus = 2)" + " and staff.ValueFlag = 1" + " and staff.AccountID = :accountID" + " and userStaff.UserID = :userID"; paras = new OracleParameter[] { new OracleParameter(":classessettingid",OracleDbType.Int32,classesSettingID,ParameterDirection.Input), new OracleParameter(":accountdate",OracleDbType.Date,accountDate,ParameterDirection.Input), new OracleParameter(":usercode",OracleDbType.Varchar2,workUserCode,ParameterDirection.Input), new OracleParameter(":accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input), new OracleParameter(":createuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":updateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input), new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input), }; result = oracleTrConn.ExecuteNonQuery(sql, paras); // 失败 if (result == Constant.INT_IS_ZERO) { return string.Format(Messages.MSG_CMN_W007, "生产工号[" + workUserCode + "]没有配置生产员工"); } #endregion } else { ClassesSettingID = int.Parse(countStr); } #endregion //#region 将班次配置表中的数据插入生产者表中 //sql = "insert into tp_pm_producer" // + " (productiondataid," // + " staffid," // + " userid," // + " usercode," // + " UJobsID," // + " staffstatus," // + " SJobsID," // + " classessettingid" // + " )" // + " select :productiondataid," // + " staffid," // + " userid," // + " usercode," // + " UJobsID," // + " staffstatus," // + " SJobsID," // + " :classessettingid" // + " from tp_pc_classesdetail" // + " where ValueFlag = 1" // + " and classessettingid = (select max(ClassesSettingID)" // + " from TP_PC_ClassesSetting" // + " where ValueFlag = 1 and AccountDate=:accountDate" // + " and UserID = :userID)"; //paras = new OracleParameter[] { // new OracleParameter(":productiondataid",OracleDbType.Int32,productionDataID,ParameterDirection.Input), // new OracleParameter(":classessettingid",OracleDbType.Int32,classesSettingID.ToString()=="0"?null:classesSettingID.ToString(),ParameterDirection.Input), // new OracleParameter(":accountDate",OracleDbType.Date,accountDate,ParameterDirection.Input), // new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input), // }; //int resultCount = oracleTrConn.ExecuteNonQuery(sql, paras); //// 失败 //if (resultCount == Constant.INT_IS_ZERO) //{ // return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); //} //#endregion return null; } /// /// 窑车生产者 /// /// 连接对象 /// 账务日期 /// 窑车生产数据ID /// 生产工号ID /// 用户基本信息 /// string private static string AddKilnCarProducer(IDBTransaction oracleTrConn, DateTime accountDate, int kilnCarDataID, int workUserID, SUserInfo sUserInfo) { // 参数 OracleParameter[] paras; #region 将班次配置表中的数据插入生产者表中 string sql = "insert into TP_PM_KilnCarProducer" + " (KilnCarDataID," + " staffid," + " userid," + " usercode," + " Ujobsid," + " staffstatus," + " Sjobsid," + " classessettingid" + " )" + " select :kilnCarDataID," + " staffid," + " userid," + " usercode," + " Ujobsid," + " staffstatus," + " Sjobsid," + " classessettingid" + " from tp_pc_classesdetail" + " where ValueFlag = 1" + " and classessettingid = (select max(ClassesSettingID)" + " from TP_PC_ClassesSetting" + " where ValueFlag = 1 and AccountDate=:accountDate" + " and UserID = :userID)"; paras = new OracleParameter[] { new OracleParameter(":kilnCarDataID",OracleDbType.Int32,kilnCarDataID,ParameterDirection.Input), new OracleParameter(":accountDate",OracleDbType.Date,accountDate,ParameterDirection.Input), new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input), }; int resultCount = oracleTrConn.ExecuteNonQuery(sql, paras); // 失败 if (resultCount == Constant.INT_IS_ZERO) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } #endregion return null; } /// /// 添加生产数据 /// /// 连接对象 /// 账务日期 /// 生产数据 /// 用户基本信息 /// string /// /// 陈冰 2014.09.18 新建 /// private static string AddProductionDataCreateTime(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag) { #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号 // string selectSql = @"select TP_PM_GroutingProduct.GroutingDate, // TP_PM_GroutingProduct.GroutingUserID, // TP_PM_GroutingProduct.GroutingUserCode, // TP_PM_GroutingProduct.GroutingNum, // TP_PM_GroutingProduct.GroutingMouldCode, // TP_PM_GroutingProduct.MouldCode, // TP_PM_GroutingDaily.GroutingDailyID, // TP_PM_GroutingDailyDetail.GroutingDailyDetailID, // TP_PM_GroutingDaily.GroutingLineID, // TP_PM_GroutingDaily.GroutingLineCode, // TP_PM_GroutingDaily.GroutingLineName, // TP_PM_GroutingDaily.GMouldTypeID, // TP_PM_GroutingDaily.CanManyTimes, // TP_PM_GroutingDailyDetail.GroutingLineDetailID // from TP_PM_GroutingProduct // left join TP_PM_GroutingDaily // on TP_PM_GroutingProduct.GroutingDailyID=TP_PM_GroutingDaily.GroutingDailyID // left join TP_PM_GroutingDailyDetail // on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_GroutingDailyDetail.GroutingDailyID // where TP_PM_GroutingProduct.barcode=:barcode"; //这地方连了两张表,为了成检的时候,次品在次新增 string returnVal = ""; string selectSql = @"select GroutingDate, GroutingUserID, GroutingUserCode, GroutingNum, GroutingMouldCode, MouldCode, GroutingDailyID, GroutingDailyDetailID, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, SpecialRepairflag from tp_pm_inproduction where barcode=:barcode union select GroutingDate, GroutingUserID, GroutingUserCode, GroutingNum, GroutingMouldCode, MouldCode, GroutingDailyID, GroutingDailyDetailID, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, SpecialRepairflag from TP_PM_InProductionTrash where barcode=:barcode "; OracleParameter[] selectparas = new OracleParameter[] { new OracleParameter(":barcode",productionData.Barcode), }; DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas); DateTime GroutingDate = new DateTime(); int GroutingUserID = 0, SpecialRepairflag = 0; string GroutingUserCode = ""; int GroutingNum = 0; string GroutingMouldCode = ""; string MouldCode = ""; //注浆日报ID int GroutingDailyID = 0; //注浆日报明细ID int GroutingDailyDetailID = 0; //成型生产线ID int GroutingLineID = 0; //成型生产线编码 string GroutingLineCode = ""; // 成型生产线名称 string GroutingLineName = ""; //成型线类型ID int GMouldTypeID = 0; // 能否多次注浆 int CanManyTimes = 0; // 成型生产线明细ID int GroutingLineDetailID = 0; if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0) { GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]); GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]); GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString(); GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]); GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString(); MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString(); GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]); GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]); GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]); GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString(); GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString(); GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]); CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]); GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]); SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]); returnVal = SpecialRepairflag.ToString(); } #endregion #region 更新窑炉窑车属性 if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4) { DataSet ds = GetKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo); if (ds != null) { if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息 { productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]); productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString(); productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString(); productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]); productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString(); productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString(); productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString(); productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]); } } } #endregion //string sql = "select createtime from TP_PM_KilnCarGoods" // + " where KilnCarID=:KilnCarID and AccountID=:AccountID"; //OracleParameter[] paras = new OracleParameter[] { // new OracleParameter(":KilnCarID",productionData.KilnCarID), // new OracleParameter(":AccountID",sUserInfo.AccountID), //}; //DataSet dsReturn = oracleTrConn.GetSqlResultToDs(sql, paras); //if (dsReturn != null && dsReturn.Tables[0].Rows.Count > 0) //{ // sql = "update TP_PM_ProductionData set " // + " CreateTime=:CreateTime" // + " where barcode=:barcode and ProcedureID=:ProcedureID and KilnCarID=:KilnCarID and AccountID=:AccountID"; // paras = new OracleParameter[] { // new OracleParameter(":CreateTime",Convert.ToDateTime(dsReturn.Tables[0].Rows[0]["CreateTime"])), // new OracleParameter(":barcode",productionData.Barcode), // new OracleParameter(":ProcedureID",productionData.CompleteProcedureID), // new OracleParameter(":KilnCarID",productionData.KilnCarID), // new OracleParameter(":AccountID",sUserInfo.AccountID), // }; // int result = oracleTrConn.ExecuteNonQuery(sql, paras); //} #region SQL string sql = "insert into tp_pm_productiondata" + " (" + " barcode," + " centralizedbatchno," + " productionlineid," + " productionlinecode," + " productionlinename," + " procedureid," + " procedurecode," + " procedurename," + " proceduremodel," + " modeltype," + " piecetype," + " isreworked," + " nodetype," + " ispublicbody," + " isrefire," + " organizationid," + " goodsid," + " goodscode," + " goodsname," + " userid," + " usercode," + " username," + " kilnid," + " kilncode," + " kilnname," + " kilncarid," + " kilncarcode," + " kilncarname," + " kilncarbatchno," + " kilncarposition," + " reworkprocedureid," + " reworkprocedurecode," + " reworkprocedurename," + " remarks," + " accountdate," + " accountid," + " GoodsLevelID," + " GoodsLevelTypeID," + " createuserid," + " updateuserid," + " GroutingDate," + " GroutingUserID," + " GroutingUserCode," + " GroutingNum," + " GroutingMouldCode," + " MouldCode," + "GroutingDailyID," + "GroutingDailyDetailID," + "GroutingLineID," + " GroutingLineCode," + "GroutingLineName," + "GMouldTypeID," + "CanManyTimes," + "GroutingLineDetailID," + "CreateTime,SpecialRepairflag" + ")" + " values" + " (" + " :barcode," + " :centralizedbatchno," + " :productionlineid," + " :productionlinecode," + " :productionlinename," + " :procedureid," + " :procedurecode," + " :procedurename," + " :proceduremodel," + " :modeltype," + " :piecetype," + " :isreworked," + " :nodetype," + " :ispublicbody," + " :isrefire," + " :organizationid," + " :goodsid," + " :goodscode," + " :goodsname," + " :userid," + " :usercode," + " :username," + " :kilnid," + " :kilncode," + " :kilnname," + " :kilncarid," + " :kilncarcode," + " :kilncarname," + " :kilncarbatchno," + " :kilncarposition," + " :reworkprocedureid," + " :reworkprocedurecode," + " :reworkprocedurename," + " :remarks," + " :accountdata," + " :accountid," + " :GoodsLevelID," + " :GoodsLevelTypeID," + " :createuserid," + " :updateuserid," + " :groutingdate," + " :groutinguserid," + " :groutingusercode," + " :groutingnum," + " :groutingmouldcode," + " :mouldcode," + ":groutingdailyid," + ":groutingdailydetailid," + ":groutinglineid," + " :groutinglinecode," + ":groutinglinename," + ":gmouldtypeid," + ":canmanytimes," + ":groutinglinedetailid," + ":CreateTime,:SpecialRepairflag" + ")"; #endregion #region OracleParameter OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":barcode",productionData.Barcode), new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo), new OracleParameter(":productionlineid",productionData.ProductionLineID), new OracleParameter(":productionlinecode",productionData.ProductionLineCode), new OracleParameter(":productionlinename",productionData.ProductionLineName), new OracleParameter(":procedureid",productionData.CompleteProcedureID), new OracleParameter(":procedurecode",productionData.ProcedureCode), new OracleParameter(":procedurename",productionData.ProcedureName), new OracleParameter(":proceduremodel",productionData.ProcedureModel), new OracleParameter(":modeltype",productionData.ModelType), new OracleParameter(":piecetype",productionData.PieceType), new OracleParameter(":isreworked",productionData.IsReworked), new OracleParameter(":nodetype",productionData.NodeType), new OracleParameter(":ispublicbody",productionData.IsPublicBody), new OracleParameter(":isrefire",productionData.IsReFire), new OracleParameter(":organizationid",productionData.OrganizationID), new OracleParameter(":goodsid",productionData.GoodsID), new OracleParameter(":goodscode",productionData.GoodsCode), new OracleParameter(":goodsname",productionData.GoodsName), new OracleParameter(":userid",productionData.UserID), new OracleParameter(":usercode",productionData.UserCode), new OracleParameter(":username",productionData.UserName), new OracleParameter(":kilnid",productionData.KilnID), new OracleParameter(":kilncode",productionData.KilnCode), new OracleParameter(":kilnname",productionData.KilnName), new OracleParameter(":kilncarid",productionData.KilnCarID), new OracleParameter(":kilncarcode",productionData.KilnCarCode), new OracleParameter(":kilncarname",productionData.KilnCarName), new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo), new OracleParameter(":kilncarposition",productionData.KilnCarPosition), new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID), new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode), new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName), new OracleParameter(":remarks",productionData.Remarks), new OracleParameter(":accountdata",accountDate), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID), new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":groutingdate",GroutingDate), new OracleParameter(":groutinguserid",GroutingUserID), new OracleParameter(":groutingusercode",GroutingUserCode), new OracleParameter(":groutingnum",GroutingNum), new OracleParameter(":groutingmouldcode",GroutingMouldCode), new OracleParameter(":mouldcode",MouldCode), new OracleParameter(":groutingdailyid",GroutingDailyID), new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID), new OracleParameter(":groutinglineid",GroutingLineID), new OracleParameter(":groutinglinecode",GroutingLineCode), new OracleParameter(":groutinglinename",GroutingLineName), new OracleParameter(":gmouldtypeid",GMouldTypeID), new OracleParameter(":canmanytimes",CanManyTimes), new OracleParameter(":groutinglinedetailid",GroutingLineDetailID), new OracleParameter(":CreateTime",productionData.CreateTime), new OracleParameter(":specialRepairflag",SpecialRepairflag), }; #endregion foreach (OracleParameter para in paras) { if (string.IsNullOrEmpty(para.Value + "")) { para.Value = DBNull.Value; } } int result = oracleTrConn.ExecuteNonQuery(sql, paras); OutSpecialRepairflag = returnVal; // 失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 成功返回null return null; } /// /// 添加生产数据 /// /// 连接对象 /// 账务日期 /// 生产数据 /// 用户基本信息 /// string /// /// 陈冰 2014.09.18 新建 /// private static string AddProductionDataDeliverMud(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag , out DataSet outGroutingProduct) { #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号 string selectSql = ""; string returnVal = ""; selectSql = @"select GroutingDate, ClassesSettingID, UserID as GroutingUserID, UserCode as GroutingUserCode, GroutingCount as GroutingNum, GroutingMouldCode, MouldCode, GroutingDailyID, GroutingDailyDetailID, GroutingLineID, GroutingLineCode, GroutingLineName, GroutingLineDetailID, SpecialRepairflag, goodsid, goodscode, goodsname, GMouldTypeID, CanManyTimes, LogoID from tp_pm_GroutingDailyDetail where tp_pm_GroutingDailyDetail.GroutingDailyDetailID=:GroutingDailyDetailID"; OracleParameter[] selectparas1 = new OracleParameter[] { new OracleParameter(":GroutingDailyDetailID",productionData.GroutingDailyDetailID), }; DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas1); DateTime GroutingDate = new DateTime(); int GroutingUserID = 0, GroutingNum = 0, GroutingDailyID = 0, GroutingDailyDetailID = 0, GroutingLineID = 0, GMouldTypeID = 0, CanManyTimes = 0, GroutingLineDetailID = 0, SpecialRepairflag = 0; string GroutingUserCode = "", GroutingMouldCode = "", MouldCode = "", GroutingLineCode = "", GroutingLineName = ""; int? ClassesSettingID = null; int? LogoID = null; if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0) { GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]); GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]); GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString(); GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]); GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString(); MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString(); GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]); GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]); GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]); GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString(); GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString(); GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]); CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]); GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]); SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]); returnVal = SpecialRepairflag.ToString(); if (productionData.IsPublicBody.ToString() != "1") ClassesSettingID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["ClassesSettingID"]); else ClassesSettingID = productionData.ClassesSettingID == null ? Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["ClassesSettingID"]) : productionData.ClassesSettingID; if (dsGroutingProduct.Tables[0].Rows[0]["LogoID"] != DBNull.Value) { LogoID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["LogoID"]); } //根据明细ID.update selectSql = "update TP_PM_GroutingDailyDetail set ispublicbody=:ispublicbody, DELIVERFLAG=1,DELIVERTIME=sysdate,deliveruserid=:deliveruserid,deliverusercode=:deliverusercode where GroutingDailyDetailID=" + GroutingDailyDetailID; OracleParameter[] paras2 = new OracleParameter[] { new OracleParameter(":deliveruserid",productionData.UserID), new OracleParameter(":deliverusercode",productionData.UserCode), new OracleParameter(":ispublicbody",productionData.IsPublicBody), }; oracleTrConn.ExecuteNonQuery(selectSql, paras2); } outGroutingProduct = dsGroutingProduct; #endregion #region 更新窑炉窑车属性 //if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4) //{ // DataSet ds = GetKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo); // if (ds != null) // { // if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息 // { // productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]); // productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString(); // productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString(); // productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]); // productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString(); // productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString(); // productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString(); // productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]); // } // } //} #endregion #region SQL string sql = "insert into tp_pm_productiondataIn" + " (productiondataid," + " barcode," + " centralizedbatchno," + " productionlineid," + " productionlinecode," + " productionlinename," + " procedureid," + " procedurecode," + " procedurename," + " proceduremodel," + " modeltype," + " piecetype," + " isreworked," + " nodetype," + " ispublicbody," + " isrefire," + " organizationid," + " goodsid," + " goodscode," + " goodsname," + " userid," + " usercode," + " username," + " kilnid," + " kilncode," + " kilnname," + " kilncarid," + " kilncarcode," + " kilncarname," + " kilncarbatchno," + " kilncarposition," + " reworkprocedureid," + " reworkprocedurecode," + " reworkprocedurename," + " remarks," + " accountdate," + " accountid," + " GoodsLevelID," + " GoodsLevelTypeID," + " createuserid," + " updateuserid," + " GroutingDate," + " GroutingUserID," + " GroutingUserCode," + " GroutingNum," + " GroutingMouldCode," + " MouldCode," + "GroutingDailyID," + "GroutingDailyDetailID," + "GroutingLineID," + " GroutingLineCode," + "GroutingLineName," + "GMouldTypeID," + "CanManyTimes," + "GroutingLineDetailID," + "SpecialRepairflag," + "ClassesSettingID," + "LogoID" + ")" + " values" + " (:productiondataid," + " :barcode," + " :centralizedbatchno," + " :productionlineid," + " :productionlinecode," + " :productionlinename," + " :procedureid," + " :procedurecode," + " :procedurename," + " :proceduremodel," + " :modeltype," + " :piecetype," + " :isreworked," + " :nodetype," + " :ispublicbody," + " :isrefire," + " :organizationid," + " :goodsid," + " :goodscode," + " :goodsname," + " :userid," + " :usercode," + " :username," + " :kilnid," + " :kilncode," + " :kilnname," + " :kilncarid," + " :kilncarcode," + " :kilncarname," + " :kilncarbatchno," + " :kilncarposition," + " :reworkprocedureid," + " :reworkprocedurecode," + " :reworkprocedurename," + " :remarks," + " :accountdata," + " :accountid," + " :GoodsLevelID," + " :GoodsLevelTypeID," + " :createuserid," + " :updateuserid," + " :groutingdate," + " :groutinguserid," + " :groutingusercode," + " :groutingnum," + " :groutingmouldcode," + " :mouldcode," + ":groutingdailyid," + ":groutingdailydetailid," + ":groutinglineid," + " :groutinglinecode," + ":groutinglinename," + ":gmouldtypeid," + ":canmanytimes," + ":groutinglinedetailid," + ":specialRepairflag," + ":classesSettingID," + ":LogoID" + ")"; #endregion #region OracleParameter OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":classesSettingID",ClassesSettingID), new OracleParameter(":productiondataid",productionData.ProductionDataID), new OracleParameter(":barcode",productionData.Barcode), new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo), new OracleParameter(":productionlineid",productionData.ProductionLineID), new OracleParameter(":productionlinecode",productionData.ProductionLineCode), new OracleParameter(":productionlinename",productionData.ProductionLineName), new OracleParameter(":procedureid",productionData.CompleteProcedureID), new OracleParameter(":procedurecode",productionData.ProcedureCode), new OracleParameter(":procedurename",productionData.ProcedureName), new OracleParameter(":proceduremodel",productionData.ProcedureModel), new OracleParameter(":modeltype",productionData.ModelType), new OracleParameter(":piecetype",productionData.PieceType), new OracleParameter(":isreworked",productionData.IsReworked), new OracleParameter(":nodetype",productionData.NodeType), new OracleParameter(":ispublicbody",productionData.IsPublicBody), new OracleParameter(":isrefire",productionData.IsReFire), new OracleParameter(":organizationid",productionData.OrganizationID), new OracleParameter(":goodsid",productionData.GoodsID), new OracleParameter(":goodscode",productionData.GoodsCode), new OracleParameter(":goodsname",productionData.GoodsName), new OracleParameter(":userid",productionData.UserID), new OracleParameter(":usercode",productionData.UserCode), new OracleParameter(":username",productionData.UserName), new OracleParameter(":kilnid",productionData.KilnID), new OracleParameter(":kilncode",productionData.KilnCode), new OracleParameter(":kilnname",productionData.KilnName), new OracleParameter(":kilncarid",productionData.KilnCarID), new OracleParameter(":kilncarcode",productionData.KilnCarCode), new OracleParameter(":kilncarname",productionData.KilnCarName), new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo), new OracleParameter(":kilncarposition",productionData.KilnCarPosition), new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID), new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode), new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName), new OracleParameter(":remarks",productionData.Remarks), new OracleParameter(":accountdata",accountDate), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID), new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":groutingdate",GroutingDate), new OracleParameter(":groutinguserid",GroutingUserID), new OracleParameter(":groutingusercode",GroutingUserCode), new OracleParameter(":groutingnum",GroutingNum), new OracleParameter(":groutingmouldcode",GroutingMouldCode), new OracleParameter(":mouldcode",MouldCode), new OracleParameter(":groutingdailyid",GroutingDailyID), new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID), new OracleParameter(":groutinglineid",GroutingLineID), new OracleParameter(":groutinglinecode",GroutingLineCode), new OracleParameter(":groutinglinename",GroutingLineName), new OracleParameter(":gmouldtypeid",GMouldTypeID), new OracleParameter(":canmanytimes",CanManyTimes), new OracleParameter(":groutinglinedetailid",GroutingLineDetailID), new OracleParameter(":specialRepairflag",SpecialRepairflag), new OracleParameter(":LogoID",LogoID), }; #endregion foreach (OracleParameter para in paras) { if (string.IsNullOrEmpty(para.Value + "")) { para.Value = DBNull.Value; } } int result = oracleTrConn.ExecuteNonQuery(sql, paras); OutSpecialRepairflag = returnVal; // 失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 成功返回null return null; } /// /// 添加生产数据 /// /// 连接对象 /// 账务日期 /// 生产数据 /// 用户基本信息 /// string /// /// 陈冰 2014.09.18 新建 /// private static string AddProductionData(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag) { #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号 string selectSql = ""; string returnVal = ""; if (productionData.NodeType == (int)Constant.ProcedureNodeType.Begin)//开始节点时从注浆登记取值 { // wangxin 20150409 删除掉TP_PM_GroutingProduct表后,进行的修改 // selectSql = @"select TP_PM_GroutingDaily.GroutingDate, // TP_PM_GroutingDailyDetail.UserID as GroutingUserID, // TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode, // TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum, // TP_PM_GroutingDailyDetail.GroutingMouldCode, // TP_PM_GroutingDailyDetail.MouldCode, // TP_PM_GroutingDailyDetail.GroutingDailyID, // TP_PM_GroutingDailyDetail.GroutingDailyDetailID, // TP_PM_GroutingDailyDetail.GroutingLineID, // TP_PM_GroutingDailyDetail.GroutingLineCode, // TP_PM_GroutingDailyDetail.GroutingLineName, // TP_PM_GroutingDaily.GMouldTypeID, // TP_PM_GroutingDaily.CanManyTimes, // TP_PM_GroutingDailyDetail.GroutingLineDetailID, // TP_PM_GroutingDailyDetail.SpecialRepairflag // from TP_PM_GroutingDaily // inner join TP_PM_GroutingDailyDetail // on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_GroutingDailyDetail.GroutingDailyID // where TP_PM_GroutingDailyDetail.barcode=:barcode"; selectSql = @"select TP_PM_GroutingDailyDetail.GroutingDate, TP_PM_GroutingDailyDetail.UserID as GroutingUserID, TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode, TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum, TP_PM_GroutingDailyDetail.GroutingMouldCode, TP_PM_GroutingDailyDetail.MouldCode, TP_PM_GroutingDailyDetail.GroutingDailyID, TP_PM_GroutingDailyDetail.GroutingDailyDetailID, TP_PM_GroutingDailyDetail.GroutingLineID, TP_PM_GroutingDailyDetail.GroutingLineCode, TP_PM_GroutingDailyDetail.GroutingLineName, TP_PM_GroutingDailyDetail.GroutingLineDetailID, TP_PM_GroutingDailyDetail.SpecialRepairflag, (select GMouldTypeID from TP_PM_GroutingDaily where TP_PM_GroutingDaily.GroutingDailyID = TP_PM_GroutingDailyDetail.GroutingDailyID) as GMouldTypeID, (select CanManyTimes from TP_PM_GroutingDaily where TP_PM_GroutingDaily.GroutingDailyID = TP_PM_GroutingDailyDetail.GroutingDailyID) as CanManyTimes, 0 as IsReFire from TP_PM_GroutingDailyDetail where TP_PM_GroutingDailyDetail.barcode=:barcode"; } else { //这地方连了两张表,为了成检的时候,次品在次新增 // selectSql = @"select // GroutingDate, // GroutingUserID, // GroutingUserCode, // GroutingNum, // GroutingMouldCode, // MouldCode, // GroutingDailyID, // GroutingDailyDetailID, // GroutingLineID, // GroutingLineCode, // GroutingLineName, // GMouldTypeID, // CanManyTimes, // GroutingLineDetailID, // SpecialRepairflag, // IsReFire // // from tp_pm_inproduction where barcode=:barcode // union // select // GroutingDate, // GroutingUserID, // GroutingUserCode, // GroutingNum, // GroutingMouldCode, // MouldCode, // GroutingDailyID, // GroutingDailyDetailID, // GroutingLineID, // GroutingLineCode, // GroutingLineName, // GMouldTypeID, // CanManyTimes, // GroutingLineDetailID, // SpecialRepairflag, // IsReFire // from TP_PM_InProductionTrash where barcode=:barcode // "; selectSql = @"select GroutingDate, GroutingUserID, GroutingUserCode, GroutingNum, GroutingMouldCode, MouldCode, GroutingDailyID, GroutingDailyDetailID, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, SpecialRepairflag, IsReFire, logoid from tp_pm_inproduction where barcode=:barcode "; } OracleParameter[] selectparas = new OracleParameter[] { new OracleParameter(":barcode",productionData.Barcode), }; DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas); DateTime GroutingDate = new DateTime(); int GroutingUserID = 0, GroutingNum = 0, GroutingDailyID = 0, GroutingDailyDetailID = 0, GroutingLineID = 0, GMouldTypeID = 0, CanManyTimes = 0, GroutingLineDetailID = 0, SpecialRepairflag = 0; string GroutingUserCode = "", GroutingMouldCode = "", MouldCode = "", GroutingLineCode = "", GroutingLineName = ""; int IsReFire = 0; int? logoID = null; if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0) { GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]); GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]); GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString(); GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]); GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString(); MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString(); GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]); GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]); GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]); GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString(); GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString(); GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]); CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]); GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]); SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]); IsReFire = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["IsReFire"]); if (IsReFire > 0) //大于零代表重烧过 { productionData.IsReFire = IsReFire; productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect; } if (dsGroutingProduct.Tables[0].Rows[0]["logoID"].ToString() != "") { logoID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["logoID"]); } //if (productionData.LogoID != null) //当前工序有商标 //{ // if (logoID != productionData.LogoID && productionData.LogoID != 0) // { // logoID = productionData.LogoID; // //根据明细ID.update // selectSql = "update TP_PM_GroutingDailyDetail set logoid=:logoid where GroutingDailyDetailID=" + GroutingDailyDetailID; // OracleParameter[] paras2 = new OracleParameter[] { // new OracleParameter(":logoid",productionData.LogoID) // }; // oracleTrConn.ExecuteNonQuery(selectSql, paras2); // } //} returnVal = SpecialRepairflag.ToString(); } #endregion #region 更新窑炉窑车属性 if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4) { DataSet ds = GetKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo); if (ds != null) { if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息 { productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]); productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString(); productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString(); productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]); productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString(); productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString(); productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString(); productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]); } } } #endregion #region SQL string sql = "insert into tp_pm_productiondataIn" + " (productiondataid," + " barcode," + " centralizedbatchno," + " productionlineid," + " productionlinecode," + " productionlinename," + " procedureid," + " procedurecode," + " procedurename," + " proceduremodel," + " modeltype," + " piecetype," + " isreworked," + " nodetype," + " ispublicbody," + " isrefire," + " organizationid," + " goodsid," + " goodscode," + " goodsname," + " userid," + " usercode," + " username," + " kilnid," + " kilncode," + " kilnname," + " kilncarid," + " kilncarcode," + " kilncarname," + " kilncarbatchno," + " kilncarposition," + " reworkprocedureid," + " reworkprocedurecode," + " reworkprocedurename," + " remarks," + " accountdate," + " accountid," + " GoodsLevelID," + " GoodsLevelTypeID," + " createuserid," + " updateuserid," + " GroutingDate," + " GroutingUserID," + " GroutingUserCode," + " GroutingNum," + " GroutingMouldCode," + " MouldCode," + "GroutingDailyID," + "GroutingDailyDetailID," + "GroutingLineID," + " GroutingLineCode," + "GroutingLineName," + "GMouldTypeID," + "CanManyTimes," + "GroutingLineDetailID," + "SpecialRepairflag," + "ClassesSettingID," + "LogoID" + ")" + " values" + " (:productiondataid," + " :barcode," + " :centralizedbatchno," + " :productionlineid," + " :productionlinecode," + " :productionlinename," + " :procedureid," + " :procedurecode," + " :procedurename," + " :proceduremodel," + " :modeltype," + " :piecetype," + " :isreworked," + " :nodetype," + " :ispublicbody," + " :isrefire," + " :organizationid," + " :goodsid," + " :goodscode," + " :goodsname," + " :userid," + " :usercode," + " :username," + " :kilnid," + " :kilncode," + " :kilnname," + " :kilncarid," + " :kilncarcode," + " :kilncarname," + " :kilncarbatchno," + " :kilncarposition," + " :reworkprocedureid," + " :reworkprocedurecode," + " :reworkprocedurename," + " :remarks," + " :accountdata," + " :accountid," + " :GoodsLevelID," + " :GoodsLevelTypeID," + " :createuserid," + " :updateuserid," + " :groutingdate," + " :groutinguserid," + " :groutingusercode," + " :groutingnum," + " :groutingmouldcode," + " :mouldcode," + ":groutingdailyid," + ":groutingdailydetailid," + ":groutinglineid," + " :groutinglinecode," + ":groutinglinename," + ":gmouldtypeid," + ":canmanytimes," + ":groutinglinedetailid," + ":specialRepairflag," + ":classesSettingID," + ":logoID" + ")"; #endregion #region OracleParameter OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":classesSettingID",productionData.ClassesSettingID), new OracleParameter(":productiondataid",productionData.ProductionDataID), new OracleParameter(":barcode",productionData.Barcode), new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo), new OracleParameter(":productionlineid",productionData.ProductionLineID), new OracleParameter(":productionlinecode",productionData.ProductionLineCode), new OracleParameter(":productionlinename",productionData.ProductionLineName), new OracleParameter(":procedureid",productionData.CompleteProcedureID), new OracleParameter(":procedurecode",productionData.ProcedureCode), new OracleParameter(":procedurename",productionData.ProcedureName), new OracleParameter(":proceduremodel",productionData.ProcedureModel), new OracleParameter(":modeltype",productionData.ModelType), new OracleParameter(":piecetype",productionData.PieceType), new OracleParameter(":isreworked",productionData.IsReworked), new OracleParameter(":nodetype",productionData.NodeType), new OracleParameter(":ispublicbody",productionData.IsPublicBody), new OracleParameter(":isrefire",productionData.IsReFire), new OracleParameter(":organizationid",productionData.OrganizationID), new OracleParameter(":goodsid",productionData.GoodsID), new OracleParameter(":goodscode",productionData.GoodsCode), new OracleParameter(":goodsname",productionData.GoodsName), new OracleParameter(":userid",productionData.UserID), new OracleParameter(":usercode",productionData.UserCode), new OracleParameter(":username",productionData.UserName), new OracleParameter(":kilnid",productionData.KilnID), new OracleParameter(":kilncode",productionData.KilnCode), new OracleParameter(":kilnname",productionData.KilnName), new OracleParameter(":kilncarid",productionData.KilnCarID), new OracleParameter(":kilncarcode",productionData.KilnCarCode), new OracleParameter(":kilncarname",productionData.KilnCarName), new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo), new OracleParameter(":kilncarposition",productionData.KilnCarPosition), new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID), new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode), new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName), new OracleParameter(":remarks",productionData.Remarks), new OracleParameter(":accountdata",accountDate), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID), new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":groutingdate",GroutingDate), new OracleParameter(":groutinguserid",GroutingUserID), new OracleParameter(":groutingusercode",GroutingUserCode), new OracleParameter(":groutingnum",GroutingNum), new OracleParameter(":groutingmouldcode",GroutingMouldCode), new OracleParameter(":mouldcode",MouldCode), new OracleParameter(":groutingdailyid",GroutingDailyID), new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID), new OracleParameter(":groutinglineid",GroutingLineID), new OracleParameter(":groutinglinecode",GroutingLineCode), new OracleParameter(":groutinglinename",GroutingLineName), new OracleParameter(":gmouldtypeid",GMouldTypeID), new OracleParameter(":canmanytimes",CanManyTimes), new OracleParameter(":groutinglinedetailid",GroutingLineDetailID), new OracleParameter(":specialRepairflag",SpecialRepairflag), new OracleParameter(":logoID",logoID), }; #endregion foreach (OracleParameter para in paras) { if (string.IsNullOrEmpty(para.Value + "")) { para.Value = DBNull.Value; } } int result = oracleTrConn.ExecuteNonQuery(sql, paras); OutSpecialRepairflag = returnVal; // 失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 成功返回null return null; } /// /// 添加生产数据(单独为成检所做,因为成检可以从次品到其它,需要读一标识,别的不需要连接回收站表) /// /// 连接对象 /// 账务日期 /// 生产数据 /// 用户基本信息 /// string /// /// 陈冰 2014.09.18 新建 /// private static string AddFinishCheckProductionData(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag) { #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号 string selectSql = ""; string returnVal = ""; if (productionData.NodeType == (int)Constant.ProcedureNodeType.Begin)//开始节点时从注浆登记取值 { // wangxin 20150409 删除掉TP_PM_GroutingProduct表后,进行的修改 // selectSql = @"select TP_PM_GroutingDaily.GroutingDate, // TP_PM_GroutingDailyDetail.UserID as GroutingUserID, // TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode, // TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum, // TP_PM_GroutingDailyDetail.GroutingMouldCode, // TP_PM_GroutingDailyDetail.MouldCode, // TP_PM_GroutingDailyDetail.GroutingDailyID, // TP_PM_GroutingDailyDetail.GroutingDailyDetailID, // TP_PM_GroutingDailyDetail.GroutingLineID, // TP_PM_GroutingDailyDetail.GroutingLineCode, // TP_PM_GroutingDailyDetail.GroutingLineName, // TP_PM_GroutingDaily.GMouldTypeID, // TP_PM_GroutingDaily.CanManyTimes, // TP_PM_GroutingDailyDetail.GroutingLineDetailID, // TP_PM_GroutingDailyDetail.SpecialRepairflag // from TP_PM_GroutingDaily // inner join TP_PM_GroutingDailyDetail // on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_GroutingDailyDetail.GroutingDailyID // where TP_PM_GroutingDailyDetail.barcode=:barcode"; selectSql = @"select TP_PM_GroutingDailyDetail.GroutingDate, TP_PM_GroutingDailyDetail.UserID as GroutingUserID, TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode, TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum, TP_PM_GroutingDailyDetail.GroutingMouldCode, TP_PM_GroutingDailyDetail.MouldCode, TP_PM_GroutingDailyDetail.GroutingDailyID, TP_PM_GroutingDailyDetail.GroutingDailyDetailID, TP_PM_GroutingDailyDetail.GroutingLineID, TP_PM_GroutingDailyDetail.GroutingLineCode, TP_PM_GroutingDailyDetail.GroutingLineName, TP_PM_GroutingDailyDetail.GroutingLineDetailID, TP_PM_GroutingDailyDetail.SpecialRepairflag, (select GMouldTypeID from TP_PM_GroutingDaily where TP_PM_GroutingDaily.GroutingDailyID = TP_PM_GroutingDailyDetail.GroutingDailyID) as GMouldTypeID, (select CanManyTimes from TP_PM_GroutingDaily where TP_PM_GroutingDaily.GroutingDailyID = TP_PM_GroutingDailyDetail.GroutingDailyID) as CanManyTimes, 0 as IsReFire from TP_PM_GroutingDailyDetail where TP_PM_GroutingDailyDetail.barcode=:barcode"; } else { //这地方连了两张表,为了成检的时候,次品在次新增 selectSql = @"select GroutingDate, GroutingUserID, GroutingUserCode, GroutingNum, GroutingMouldCode, MouldCode, GroutingDailyID, GroutingDailyDetailID, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, SpecialRepairflag, IsReFire, Logoid from tp_pm_inproduction where barcode=:barcode union select GroutingDate, GroutingUserID, GroutingUserCode, GroutingNum, GroutingMouldCode, MouldCode, GroutingDailyID, GroutingDailyDetailID, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, SpecialRepairflag, IsReFire, logoid from TP_PM_InProductionTrash where barcode=:barcode "; } OracleParameter[] selectparas = new OracleParameter[] { new OracleParameter(":barcode",productionData.Barcode), }; DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas); DateTime GroutingDate = new DateTime(); int GroutingUserID = 0, GroutingNum = 0, GroutingDailyID = 0, GroutingDailyDetailID = 0, GroutingLineID = 0, GMouldTypeID = 0, CanManyTimes = 0, GroutingLineDetailID = 0, SpecialRepairflag = 0; string GroutingUserCode = "", GroutingMouldCode = "", MouldCode = "", GroutingLineCode = "", GroutingLineName = ""; int IsReFire = 0; int? logoid = null; if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0) { GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]); GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]); GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString(); GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]); GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString(); MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString(); GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]); GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]); GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]); GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString(); GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString(); GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]); CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]); GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]); SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]); IsReFire = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["IsReFire"]); if (dsGroutingProduct.Tables[0].Rows[0]["logoid"].ToString() != "") { logoid = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["logoid"]); } if (IsReFire > 0) //大于零代表重烧过 { productionData.IsReFire = IsReFire; productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect; } returnVal = SpecialRepairflag.ToString(); } #endregion #region 更新窑炉窑车属性 if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4) { DataSet ds = GetFinishCheckKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo); if (ds != null) { if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息 { productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]); productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString(); productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString(); productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]); productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString(); productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString(); productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString(); productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]); } } } #endregion if (Convert.ToInt32(productionData.GoodsLevelTypeID) == 6) //判断重烧必须有返工工序 { if (productionData.ReworkProcedureID == null || Convert.ToInt32(productionData.ReworkProcedureID) == 0) { OutSpecialRepairflag = ""; return string.Format("产品分级【重烧】必须填写返工工序", "条码", "保存"); } } DateTime? checkTime = null; if (productionData.IsPDA != null) { if (productionData.PDACheckTime != null) { // PDA端 if (productionData.PDACheckTime.ToString() != string.Empty) { checkTime = Convert.ToDateTime(productionData.PDACheckTime); } } } else { if (productionData.CheckTime != null) { // PDA端 if (productionData.CheckTime.ToString() != string.Empty) { checkTime = Convert.ToDateTime(productionData.CheckTime); } } } #region SQL string sql = "insert into tp_pm_productiondataIn" + " (productiondataid," + " barcode," + " centralizedbatchno," + " productionlineid," + " productionlinecode," + " productionlinename," + " procedureid," + " procedurecode," + " procedurename," + " proceduremodel," + " modeltype," + " piecetype," + " isreworked," + " nodetype," + " ispublicbody," + " isrefire," + " organizationid," + " goodsid," + " goodscode," + " goodsname," + " userid," + " usercode," + " username," + " kilnid," + " kilncode," + " kilnname," + " kilncarid," + " kilncarcode," + " kilncarname," + " kilncarbatchno," + " kilncarposition," + " reworkprocedureid," + " reworkprocedurecode," + " reworkprocedurename," + " remarks," + " accountdate," + " accountid," + " GoodsLevelID," + " GoodsLevelTypeID," + " createuserid," + " updateuserid," + " GroutingDate," + " GroutingUserID," + " GroutingUserCode," + " GroutingNum," + " GroutingMouldCode," + " MouldCode," + "GroutingDailyID," + "GroutingDailyDetailID," + "GroutingLineID," + " GroutingLineCode," + "GroutingLineName," + "GMouldTypeID," + "CanManyTimes," + "GroutingLineDetailID," + "SpecialRepairflag," + "ClassesSettingID," + "LogoID," + "CheckTime" + ")" + " values" + " (:productiondataid," + " :barcode," + " :centralizedbatchno," + " :productionlineid," + " :productionlinecode," + " :productionlinename," + " :procedureid," + " :procedurecode," + " :procedurename," + " :proceduremodel," + " :modeltype," + " :piecetype," + " :isreworked," + " :nodetype," + " :ispublicbody," + " :isrefire," + " :organizationid," + " :goodsid," + " :goodscode," + " :goodsname," + " :userid," + " :usercode," + " :username," + " :kilnid," + " :kilncode," + " :kilnname," + " :kilncarid," + " :kilncarcode," + " :kilncarname," + " :kilncarbatchno," + " :kilncarposition," + " :reworkprocedureid," + " :reworkprocedurecode," + " :reworkprocedurename," + " :remarks," + " :accountdata," + " :accountid," + " :GoodsLevelID," + " :GoodsLevelTypeID," + " :createuserid," + " :updateuserid," + " :groutingdate," + " :groutinguserid," + " :groutingusercode," + " :groutingnum," + " :groutingmouldcode," + " :mouldcode," + ":groutingdailyid," + ":groutingdailydetailid," + ":groutinglineid," + " :groutinglinecode," + ":groutinglinename," + ":gmouldtypeid," + ":canmanytimes," + ":groutinglinedetailid," + ":specialRepairflag," + ":classesSettingID," + ":logoid,"; if (checkTime == null) { sql = sql + "sysdate"; } else { sql = sql + ":checkTime"; } sql = sql + ")"; #endregion #region OracleParameter OracleParameter[] paras = null; if (checkTime != null) { paras = new OracleParameter[] { new OracleParameter(":classesSettingID",productionData.ClassesSettingID), new OracleParameter(":productiondataid",productionData.ProductionDataID), new OracleParameter(":barcode",productionData.Barcode), new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo), new OracleParameter(":productionlineid",productionData.ProductionLineID), new OracleParameter(":productionlinecode",productionData.ProductionLineCode), new OracleParameter(":productionlinename",productionData.ProductionLineName), new OracleParameter(":procedureid",productionData.CompleteProcedureID), new OracleParameter(":procedurecode",productionData.ProcedureCode), new OracleParameter(":procedurename",productionData.ProcedureName), new OracleParameter(":proceduremodel",productionData.ProcedureModel), new OracleParameter(":modeltype",productionData.ModelType), new OracleParameter(":piecetype",productionData.PieceType), new OracleParameter(":isreworked",productionData.IsReworked), new OracleParameter(":nodetype",productionData.NodeType), new OracleParameter(":ispublicbody",productionData.IsPublicBody), new OracleParameter(":isrefire",productionData.IsReFire), new OracleParameter(":organizationid",productionData.OrganizationID), new OracleParameter(":goodsid",productionData.GoodsID), new OracleParameter(":goodscode",productionData.GoodsCode), new OracleParameter(":goodsname",productionData.GoodsName), new OracleParameter(":userid",productionData.UserID), new OracleParameter(":usercode",productionData.UserCode), new OracleParameter(":username",productionData.UserName), new OracleParameter(":kilnid",productionData.KilnID), new OracleParameter(":kilncode",productionData.KilnCode), new OracleParameter(":kilnname",productionData.KilnName), new OracleParameter(":kilncarid",productionData.KilnCarID), new OracleParameter(":kilncarcode",productionData.KilnCarCode), new OracleParameter(":kilncarname",productionData.KilnCarName), new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo), new OracleParameter(":kilncarposition",productionData.KilnCarPosition), new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID), new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode), new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName), new OracleParameter(":remarks",productionData.Remarks), new OracleParameter(":accountdata",accountDate), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID), new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":groutingdate",GroutingDate), new OracleParameter(":groutinguserid",GroutingUserID), new OracleParameter(":groutingusercode",GroutingUserCode), new OracleParameter(":groutingnum",GroutingNum), new OracleParameter(":groutingmouldcode",GroutingMouldCode), new OracleParameter(":mouldcode",MouldCode), new OracleParameter(":groutingdailyid",GroutingDailyID), new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID), new OracleParameter(":groutinglineid",GroutingLineID), new OracleParameter(":groutinglinecode",GroutingLineCode), new OracleParameter(":groutinglinename",GroutingLineName), new OracleParameter(":gmouldtypeid",GMouldTypeID), new OracleParameter(":canmanytimes",CanManyTimes), new OracleParameter(":groutinglinedetailid",GroutingLineDetailID), new OracleParameter(":specialRepairflag",SpecialRepairflag), new OracleParameter(":logoid",logoid), new OracleParameter(":checkTime",checkTime), }; } else { paras = new OracleParameter[] { new OracleParameter(":classesSettingID",productionData.ClassesSettingID), new OracleParameter(":productiondataid",productionData.ProductionDataID), new OracleParameter(":barcode",productionData.Barcode), new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo), new OracleParameter(":productionlineid",productionData.ProductionLineID), new OracleParameter(":productionlinecode",productionData.ProductionLineCode), new OracleParameter(":productionlinename",productionData.ProductionLineName), new OracleParameter(":procedureid",productionData.CompleteProcedureID), new OracleParameter(":procedurecode",productionData.ProcedureCode), new OracleParameter(":procedurename",productionData.ProcedureName), new OracleParameter(":proceduremodel",productionData.ProcedureModel), new OracleParameter(":modeltype",productionData.ModelType), new OracleParameter(":piecetype",productionData.PieceType), new OracleParameter(":isreworked",productionData.IsReworked), new OracleParameter(":nodetype",productionData.NodeType), new OracleParameter(":ispublicbody",productionData.IsPublicBody), new OracleParameter(":isrefire",productionData.IsReFire), new OracleParameter(":organizationid",productionData.OrganizationID), new OracleParameter(":goodsid",productionData.GoodsID), new OracleParameter(":goodscode",productionData.GoodsCode), new OracleParameter(":goodsname",productionData.GoodsName), new OracleParameter(":userid",productionData.UserID), new OracleParameter(":usercode",productionData.UserCode), new OracleParameter(":username",productionData.UserName), new OracleParameter(":kilnid",productionData.KilnID), new OracleParameter(":kilncode",productionData.KilnCode), new OracleParameter(":kilnname",productionData.KilnName), new OracleParameter(":kilncarid",productionData.KilnCarID), new OracleParameter(":kilncarcode",productionData.KilnCarCode), new OracleParameter(":kilncarname",productionData.KilnCarName), new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo), new OracleParameter(":kilncarposition",productionData.KilnCarPosition), new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID), new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode), new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName), new OracleParameter(":remarks",productionData.Remarks), new OracleParameter(":accountdata",accountDate), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID), new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":groutingdate",GroutingDate), new OracleParameter(":groutinguserid",GroutingUserID), new OracleParameter(":groutingusercode",GroutingUserCode), new OracleParameter(":groutingnum",GroutingNum), new OracleParameter(":groutingmouldcode",GroutingMouldCode), new OracleParameter(":mouldcode",MouldCode), new OracleParameter(":groutingdailyid",GroutingDailyID), new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID), new OracleParameter(":groutinglineid",GroutingLineID), new OracleParameter(":groutinglinecode",GroutingLineCode), new OracleParameter(":groutinglinename",GroutingLineName), new OracleParameter(":gmouldtypeid",GMouldTypeID), new OracleParameter(":canmanytimes",CanManyTimes), new OracleParameter(":groutinglinedetailid",GroutingLineDetailID), new OracleParameter(":specialRepairflag",SpecialRepairflag), new OracleParameter(":logoid",logoid), }; } #endregion foreach (OracleParameter para in paras) { if (string.IsNullOrEmpty(para.Value + "")) { para.Value = DBNull.Value; } } int result = oracleTrConn.ExecuteNonQuery(sql, paras); OutSpecialRepairflag = returnVal; // 失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 成功返回null return null; } /// /// 删除在产数据 /// /// 连接对象 /// 在产数据对象 /// string /// /// 陈冰 2014.09.18 新建 /// private static string DeleteInProduction(IDBTransaction oracleTrConn, InProductionEntity delInProductionEntity, bool FinishedProduct, SUserInfo sUserInfo) { OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":barcode",delInProductionEntity.BarCode), }; int result = 0; //删除在产表之前,插入到产品回收表中 if (!FinishedProduct)//如果不是产成品的时候,就是报废,产成品的时候不添加这个表里,只删除在产数据 { OracleParameter[] parasPDA = new OracleParameter[] { new OracleParameter(":CreateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":barcode",delInProductionEntity.BarCode), new OracleParameter(":FlowProcedureID",delInProductionEntity.CompleteProcedureID), }; string sqlInsert = @"insert into TP_PM_InProductionTrash ( BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, CreateTime, CreateUserID, UpdateUserID, SpecialRepairflag, FlowProcedureID, FlowProcedureTime, ProcedureID, ProcedureTime, ProductionDataID, logoid, ISREWORKFLAG, SEMICHECKID ) select BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, CreateTime, :CreateUserID, :UpdateUserID, SpecialRepairflag, :FlowProcedureID, FlowProcedureTime, :FlowProcedureID, ProcedureTime, ProductionDataID, logoid, ISREWORKFLAG, SEMICHECKID from TP_PM_InProduction where barcode=:barcode "; result = oracleTrConn.ExecuteNonQuery(sqlInsert, parasPDA); } string sql = "delete tp_pm_inproduction where barcode = :barcode"; result += oracleTrConn.ExecuteNonQuery(sql, paras); // 删除失败 //if (result != Constant.INT_IS_TWO)//删除在产的同时,应该往产品加收表里插入,这样就是影响行数为2,以前是1 if (result == Constant.INT_IS_ZERO) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 成功返回null return null; } /// /// 删除在产数据 /// /// 连接对象 /// 在产数据对象 /// string /// /// 陈冰 2014.09.18 新建 /// private static string DeletePDAInProduction(IDBTransaction oracleTrConn, InProductionEntity delInProductionEntity, bool FinishedProduct, SUserInfo sUserInfo) { OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":barcode",delInProductionEntity.BarCode), }; int result = 0; //删除在产表之前,插入到产品回收表中 if (!FinishedProduct)//如果不是产成品的时候,就是报废,产成品的时候不添加这个表里,只删除在产数据 { OracleParameter[] parasPDA = new OracleParameter[] { new OracleParameter(":barcode",delInProductionEntity.BarCode), new OracleParameter(":FlowProcedureID",delInProductionEntity.CompleteProcedureID), new OracleParameter(":CreateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":ProductionDataID",OracleDbType.Int32,delInProductionEntity.ProductionDataID,ParameterDirection.Input), new OracleParameter(":GoodsLevelID",OracleDbType.Int32,delInProductionEntity.GoodsLevelID,ParameterDirection.Input), new OracleParameter(":GoodsLevelTypeID",OracleDbType.Int32,delInProductionEntity.GoodsLevelTypeID,ParameterDirection.Input), }; //删除在产表前,在产表生产数据ID更新下,如不更新这样就不准了,例如,次品到次品 第一次不会影响,因为第一次TP_PM_InProductionTrash表里没有 // 如果第二次走次品到次品,才有效,下面的sqlInsert则没有效,因为在产表里没有数据插入不到回收表 string sqlupdate = "update TP_PM_InProductionTrash set ProductionDataID=:ProductionDataID where barcode=:barcode"; OracleParameter[] parasupdate = new OracleParameter[] { new OracleParameter(":barcode",delInProductionEntity.BarCode), new OracleParameter(":ProductionDataID",delInProductionEntity.ProductionDataID), }; oracleTrConn.ExecuteNonQuery(sqlupdate, parasupdate); string sqlInsert = @"insert into TP_PM_InProductionTrash ( BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, CreateUserID, UpdateUserID, SpecialRepairflag, FlowProcedureID, FlowProcedureTime, ProcedureID, ProcedureTime, ProductionDataID, logoid, ISREWORKFLAG, SEMICHECKID ) select BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, :GoodsLevelID, :GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, :CreateUserID, :UpdateUserID, SpecialRepairflag, :FlowProcedureID, FlowProcedureTime, :FlowProcedureID, ProcedureTime, :ProductionDataID, logoid, ISREWORKFLAG, SEMICHECKID from TP_PM_InProduction where barcode=:barcode "; result = oracleTrConn.ExecuteNonQuery(sqlInsert, parasPDA); } string sql = "delete tp_pm_inproduction where barcode = :barcode"; result += oracleTrConn.ExecuteNonQuery(sql, paras); // 删除失败 //if (result != Constant.INT_IS_TWO)//删除在产的同时,应该往产品加收表里插入,这样就是影响行数为2,以前是1 if (result == Constant.INT_IS_ZERO) { //return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 成功返回null return null; } /// /// 根据窑车ID 删除窑车产品 /// /// 数据连接 /// 窑车ID /// /// 张国印 2014.10.04 新建 /// private static string DeleteKilnCarGoodsByKilnCarID(IDBTransaction oracleTrConn, int pKilnCarID) { string sql = "delete TP_PM_KilnCarGoods where KilnCarID = :pKilnCarID"; OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":pKilnCarID", OracleDbType.Int32, pKilnCarID, ParameterDirection.Input), }; int result = oracleTrConn.ExecuteNonQuery(sql, paras); // 删除失败 if (result <= Constant.INT_IS_ZERO) { return string.Format(Messages.MSG_CMN_W001, "窑车产品", "保存"); } // 成功返回null return null; } /// /// 添加产成品 /// /// 连接对象 /// 产成品对象 /// 用户基本信息 /// string /// /// 陈冰 2014.09.18 新建 /// private static string AddFinishedProduct(IDBTransaction oracleTrConn, FinishedProductEntity finishedProduct, SUserInfo sUserInfo , string finishedloadbatchno) { List paras = new List(); string sql = ""; #region // add 2015/11/16 // if (finishedProduct.LogoID != null && Convert.ToInt32(finishedProduct.LogoID) > 0) // { // #region SQL // //废弃 // sql = " insert into tp_pm_finishedproduct" // + " (barcode, " // + " productionlineid, " // + " productionlinecode, " // + " productionlinename, " // + " ispublicbody, " // + " isrefire, " // + " GoodsLevelID, " // + " GoodsLevelTypeID, " // + " goodsid, " // + " goodscode, " // + " goodsname, " // + " groutingdailyid, " // + " groutingdailydetailid, " // + " groutingdate, " // + " groutinglineid, " // + " groutinglinecode, " // + " groutinglinename, " // + " gmouldtypeid, " // + " groutinglinedetailid, " // + " groutingmouldcode, " // + " mouldcode, " // + " accountdate, " // + " accountid, " // + " createuserid, " // + " updateuserid," // + " groutinguserid, " // + " groutingusercode, " // + " groutingnum, " // + " kilnid, " // + " kilncode, " // + " kilnname, " // + " kilncarid, " // + " kilncarcode, " // + " kilncarname, " // + " kilncarbatchno, " // + " kilncarposition, " // + " specialRepairflag, " // + " logoid " // + ") " // + " select barcode, " // + " productionlineid, " // + " productionlinecode, " // + " productionlinename, " // + " ispublicbody, " // + " isrefire, "; // #region 产品等级 // //if (finishedProduct.GoodsGrade == null) // //{ // // sql = sql + " goodsgrade,"; // //} // //// 最后一个工序如果是检验工序,可更改产品等级 // //else // //{ // // sql = sql + " :goodsgrade, "; // // paras.Add(new OracleParameter(":goodsgrade", finishedProduct.GoodsGrade)); // //} // //如果包装时,产成品未走过成检,则直接视为正品 // int? GoodsLevelTypeID = null; // int? GoodsLevelID = null; // if (finishedProduct.GoodsLevelID == null) // { // string sqlQuery = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID= // ( // select distinct GoodsLevelTypeID from tp_pm_inproduction where Barcode='" + finishedProduct.BarCode + "'" + // ") and AccountID=" + sUserInfo.AccountID; // DataSet ds = oracleTrConn.GetSqlResultToDs(sqlQuery); // if (ds != null && ds.Tables[0].Rows.Count > 0) // { // if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "") // { // if (Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 5)//副品 // { // GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]); // GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]); // } // else // { // string sqlQuery2 = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=4 and AccountID=" + sUserInfo.AccountID; // ds = oracleTrConn.GetSqlResultToDs(sqlQuery2); // if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "") // { // GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]); // GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]); // } // } // } // } // else // { // string sqlQuery2 = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=4 and AccountID=" + sUserInfo.AccountID; // ds = oracleTrConn.GetSqlResultToDs(sqlQuery2); // if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "") // { // GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]); // GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]); // } // } // } // if (finishedProduct.GoodsLevelID == null) // { // //sql = sql + " GoodsLevelID,"; // // 包装后,这个值并没有,这里的值除了在检验的时候会给赋值,其它工序应该没有设置,所以查询了一次 // ////// sql = sql + @" // ////// (select GoodsLevelID from TP_MST_GoodsLevel where GoodsLevelTypeID= // ////// ( // ////// select distinct GoodsLevelTypeID from tp_pm_inproduction where Barcode=:barcode // ////// ) and AccountID=:AccountID),"; // sql = sql + GoodsLevelID.ToString() + " ,"; // } // // 最后一个工序如果是检验工序,可更改产品等级 // else // { // sql = sql + " :GoodsLevelID, "; // paras.Add(new OracleParameter(":GoodsLevelID", finishedProduct.GoodsLevelID)); // } // if (finishedProduct.GoodsLevelTypeID == null) // { // //sql = sql + " GoodsLevelTypeID,"; // sql = sql + GoodsLevelTypeID.ToString() + " ,"; // } // // 最后一个工序如果是检验工序,可更改产品等级 // else // { // sql = sql + " :GoodsLevelTypeID, "; // paras.Add(new OracleParameter(":GoodsLevelTypeID", finishedProduct.GoodsLevelTypeID)); // } // #endregion // sql = sql + " goodsid, " // + " goodscode, " // + " goodsname, " // + " groutingdailyid, " // + " groutingdailydetailid, " // + " groutingdate, " // + " groutinglineid, " // + " groutinglinecode, " // + " groutinglinename, " // + " gmouldtypeid, " // + " groutinglinedetailid, " // + " groutingmouldcode, " // + " mouldcode, " // + " fun_cmn_getaccountdate(accountid), " // + " accountid, " // + " :createuserid, " // + " :updateuserid, " // + " groutinguserid, " // + " groutingusercode, " // + " groutingnum, " // + " kilnid, " // + " kilncode, " // + " kilnname, " // + " kilncarid, " // + " kilncarcode, " // + " kilncarname, " // + " kilncarbatchno, " // + " kilncarposition, " // + " specialRepairflag, " // + " :logoid " // + " from tp_pm_inproduction " // + " where Barcode=:barcode"; // #endregion // paras.Add(new OracleParameter(":createuserid", sUserInfo.UserID)); // paras.Add(new OracleParameter(":updateuserid", sUserInfo.UserID)); // paras.Add(new OracleParameter(":barcode", finishedProduct.BarCode)); // paras.Add(new OracleParameter(":logoid", finishedProduct.LogoID)); // // end 2015/11/16 // } // else // { #endregion #region SQL //废弃 sql = " insert into tp_pm_finishedproduct" + " (barcode, " + " productionlineid, " + " productionlinecode, " + " productionlinename, " + " ispublicbody, " + " isrefire, " + " GoodsLevelID, " + " GoodsLevelTypeID, " + " goodsid, " + " goodscode, " + " goodsname, " + " groutingdailyid, " + " groutingdailydetailid, " + " groutingdate, " + " groutinglineid, " + " groutinglinecode, " + " groutinglinename, " + " gmouldtypeid, " + " groutinglinedetailid, " + " groutingmouldcode, " + " mouldcode, " + " accountdate, " + " accountid, " + " createuserid, " + " updateuserid," + " groutinguserid, " + " groutingusercode, " + " groutingnum, " + " kilnid, " + " kilncode, " + " kilnname, " + " kilncarid, " + " kilncarcode, " + " kilncarname, " + " kilncarbatchno, " + " kilncarposition, " + " specialRepairflag, " + " logoid,OnlyCode ,finishedloadbatchno" + ") " + " select barcode, " + " productionlineid, " + " productionlinecode, " + " productionlinename, " + " ispublicbody, " + " isrefire, "; #region 产品等级 //if (finishedProduct.GoodsGrade == null) //{ // sql = sql + " goodsgrade,"; //} //// 最后一个工序如果是检验工序,可更改产品等级 //else //{ // sql = sql + " :goodsgrade, "; // paras.Add(new OracleParameter(":goodsgrade", finishedProduct.GoodsGrade)); //} //如果包装时,产成品未走过成检,则直接视为正品 int? GoodsLevelTypeID = null; int? GoodsLevelID = null; if (finishedProduct.GoodsLevelID == null) { string sqlQuery = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID= ( select distinct GoodsLevelTypeID from tp_pm_inproduction where Barcode='" + finishedProduct.BarCode + "'" + ") and AccountID=" + sUserInfo.AccountID; DataSet ds = oracleTrConn.GetSqlResultToDs(sqlQuery); if (ds != null && ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "") { if (Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 5)//副品 { GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]); GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]); } else if (Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 4)//正品 { string sqlQuery2 = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=4 and AccountID=" + sUserInfo.AccountID; ds = oracleTrConn.GetSqlResultToDs(sqlQuery2); if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "") { GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]); GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]); } } else { GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]); GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]); } } } else { string sqlQuery2 = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=4 and AccountID=" + sUserInfo.AccountID; ds = oracleTrConn.GetSqlResultToDs(sqlQuery2); if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "") { GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]); GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]); } } } if (finishedProduct.GoodsLevelID == null) { //sql = sql + " GoodsLevelID,"; // 包装后,这个值并没有,这里的值除了在检验的时候会给赋值,其它工序应该没有设置,所以查询了一次 ////// sql = sql + @" ////// (select GoodsLevelID from TP_MST_GoodsLevel where GoodsLevelTypeID= ////// ( ////// select distinct GoodsLevelTypeID from tp_pm_inproduction where Barcode=:barcode ////// ) and AccountID=:AccountID),"; sql = sql + GoodsLevelID.ToString() + " ,"; } // 最后一个工序如果是检验工序,可更改产品等级 else { sql = sql + " :GoodsLevelID, "; paras.Add(new OracleParameter(":GoodsLevelID", finishedProduct.GoodsLevelID)); } if (finishedProduct.GoodsLevelTypeID == null) { //sql = sql + " GoodsLevelTypeID,"; sql = sql + GoodsLevelTypeID.ToString() + " ,"; } // 最后一个工序如果是检验工序,可更改产品等级 else { sql = sql + " :GoodsLevelTypeID, "; paras.Add(new OracleParameter(":GoodsLevelTypeID", finishedProduct.GoodsLevelTypeID)); } #endregion sql = sql + " goodsid, " + " goodscode, " + " goodsname, " + " groutingdailyid, " + " groutingdailydetailid, " + " groutingdate, " + " groutinglineid, " + " groutinglinecode, " + " groutinglinename, " + " gmouldtypeid, " + " groutinglinedetailid, " + " groutingmouldcode, " + " mouldcode, " + " fun_cmn_getaccountdate(accountid), " + " accountid, " + " :createuserid, " + " :updateuserid, " + " groutinguserid, " + " groutingusercode, " + " groutingnum, " + " kilnid, " + " kilncode, " + " kilnname, " + " kilncarid, " + " kilncarcode, " + " kilncarname, " + " kilncarbatchno, " + " kilncarposition, " + " specialRepairflag, " + " logoid, " + " (select OnlyCode from tp_pm_groutingdailydetail where barcode=:barcode), :finishedloadbatchno" + " from tp_pm_inproduction " + " where Barcode=:barcode"; #endregion paras.Add(new OracleParameter(":createuserid", sUserInfo.UserID)); paras.Add(new OracleParameter(":updateuserid", sUserInfo.UserID)); paras.Add(new OracleParameter(":barcode", finishedProduct.BarCode)); paras.Add(new OracleParameter(":finishedloadbatchno", finishedloadbatchno)); //} //paras.Add(new OracleParameter(":AccountID", sUserInfo.AccountID)); int result = oracleTrConn.ExecuteNonQuery(sql, paras.ToArray()); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 保存成功返回null return null; } /// /// 添加在产产品数据 /// /// 连接对象 /// 在产产品实体类 /// 用户基本信息 /// string /// /// 陈冰 2014.09.18 新建 /// private static string AddInProduction(IDBTransaction oracleTrConn, InProductionEntity inProduction, SUserInfo sUserInfo, DataSet _dsDataset) { #region SQL string sqlExist = "select 1 from tp_pm_inproduction where barcode = :barcode "; OracleParameter[] parasExist = new OracleParameter[] { new OracleParameter(":barcode",inProduction.BarCode.Trim()), }; DataSet dsresult = oracleTrConn.GetSqlResultToDs(sqlExist, parasExist); if (dsresult != null && dsresult.Tables[0].Rows.Count == 0) { // 获取生产线ID,生产线名称,生产编码 string sql = @"select TP_PC_ProductionLine.ProductionLineID,TP_PC_ProductionLine.ProductionLineCode,TP_PC_ProductionLine.ProductionLineName from TP_PC_Procedure inner join TP_PC_ProductionLine on TP_PC_Procedure.ProductionLineID=TP_PC_ProductionLine.ProductionLineID where TP_PC_Procedure.ProcedureID=:ProcedureID "; OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":ProcedureID",inProduction.FlowProcedureID), }; dsresult = oracleTrConn.GetSqlResultToDs(sql, paras); #region 获取生产线信息 int ProductionLineID = 0;//生产线ID string ProductionLineCode = "", ProductionLineName = "";//生产线名称,编码 if (dsresult != null && dsresult.Tables[0].Rows.Count > 0) { ProductionLineID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["ProductionLineID"]); ProductionLineCode = dsresult.Tables[0].Rows[0]["ProductionLineCode"].ToString(); ProductionLineName = dsresult.Tables[0].Rows[0]["ProductionLineName"].ToString(); } #endregion #region 获取注浆信息 // sql = @"select // TP_PM_GroutingDailyDetail.UserID as GroutingUserID, // TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode, // TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum, // TP_PM_GroutingDailyDetail.GroutingMouldCode, // TP_PM_GroutingDailyDetail.MouldCode, // TP_PM_GroutingDailyDetail.GroutingDailyID, // TP_PM_GroutingDailyDetail.GroutingDailyDetailID, // TP_PM_GroutingDailyDetail.GroutingLineID, // TP_PM_GroutingDailyDetail.GroutingLineCode, // TP_PM_GroutingDailyDetail.GroutingLineName, // TP_PM_GroutingDaily.GMouldTypeID, // TP_PM_GroutingDaily.CanManyTimes, // TP_PM_GroutingDailyDetail.GroutingLineDetailID, // TP_PM_GroutingDailyDetail.SpecialRepairflag, // TP_PM_GroutingDailyDetail.GoodsID, // TP_PM_GroutingDailyDetail.GoodsCode, // TP_PM_GroutingDailyDetail.GoodsName, // TP_PM_GroutingDailyDetail.GroutingDate // from TP_PM_GroutingDaily // inner join TP_PM_GroutingDailyDetail // on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_GroutingDailyDetail.GroutingDailyID // where TP_PM_GroutingDailyDetail.barcode=:barcode"; // sql = @"select // UserID as GroutingUserID, // UserCode as GroutingUserCode, // GroutingCount as GroutingNum, // GroutingMouldCode, // MouldCode, // GroutingDailyID, // GroutingDailyDetailID, // GroutingLineID, // GroutingLineCode, // GroutingLineName, // GroutingLineDetailID, // SpecialRepairflag, // GoodsID, // GoodsCode, // GoodsName, // GroutingDate, // (select GMouldTypeID // from TP_PM_GroutingDaily // where TP_PM_GroutingDaily.GroutingDailyID = // TP_PM_GroutingDailyDetail.GroutingDailyID) as GMouldTypeID, // (select CanManyTimes // from TP_PM_GroutingDaily // where TP_PM_GroutingDaily.GroutingDailyID = // TP_PM_GroutingDailyDetail.GroutingDailyID) as CanManyTimes // from TP_PM_GroutingDailyDetail // where TP_PM_GroutingDailyDetail.barcode=:barcode"; // sql = @"select // GroutingUserID, // GroutingUserCode, // GroutingNum, // GroutingMouldCode, // MouldCode, // GroutingDailyID, // GroutingDailyDetailID, // GroutingLineID, // GroutingLineCode, // GroutingLineName, // GroutingLineDetailID, // SpecialRepairflag, // GoodsID, // GoodsCode, // GoodsName, // GroutingDate, // GMouldTypeID // CanManyTimes // from tp_pm_productiondata // where tp_pm_productiondata.barcode=:barcode"; // paras = new OracleParameter[] { // new OracleParameter(":barcode",inProduction.BarCode), // }; dsresult = _dsDataset; //dsresult = oracleTrConn.GetSqlResultToDs(sql, paras); // 产品ID, 注浆登记ID, 注浆明细ID, 成型线ID 成型线类型ID 能否多次注浆 成型生产线明细ID int goodsid = 0, groutingDailyID = 0, groutingdailydetailid = 0, groutinglineid = 0, gMouldTypeID = 0, canManyTimes = 0, groutingLineDetailID = 0; // 产品编码, 产品名称 成型线编码 成型线名称 注浆模具编号 模具编号 string goodsCode = "", goodsName = "", groutingLineCode = "", groutingLineName = "", groutingmouldcode = "", mouldCode = ""; DateTime? groutingdate = null; // 注浆日期 int groutingUserID = 0, groutingNum = 0; //注浆工号ID,注浆次数 string groutingUserCode = "";//注浆工号 int? LogoID = null; if (dsresult != null && dsresult.Tables[0].Rows.Count > 0) { goodsid = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GoodsID"]); groutingDailyID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingDailyID"]); groutingdailydetailid = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingDailyDetailID"]); groutinglineid = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingLineID"]); groutingLineDetailID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingLineDetailID"]); groutingdate = Convert.ToDateTime(dsresult.Tables[0].Rows[0]["GroutingDate"]); goodsCode = dsresult.Tables[0].Rows[0]["GoodsCode"].ToString(); goodsName = dsresult.Tables[0].Rows[0]["GoodsName"].ToString(); groutingLineCode = dsresult.Tables[0].Rows[0]["GroutingLineCode"].ToString(); groutingLineName = dsresult.Tables[0].Rows[0]["GroutingLineName"].ToString(); groutingmouldcode = dsresult.Tables[0].Rows[0]["GroutingMouldCode"].ToString(); mouldCode = dsresult.Tables[0].Rows[0]["MouldCode"].ToString(); groutingUserCode = dsresult.Tables[0].Rows[0]["GroutingUserCode"].ToString(); groutingUserID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingUserID"]); gMouldTypeID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GMouldTypeID"]); canManyTimes = Convert.ToInt32(dsresult.Tables[0].Rows[0]["CanManyTimes"]); groutingNum = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingNum"]); if (dsresult.Tables[0].Rows[0]["logoid"].ToString() != "") { LogoID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["logoid"]); } } #endregion sql = " insert into tp_pm_inproduction" + " ( barcode," + " productionlineid," + " productionlinecode," + " productionlinename," + " proceduremodel," + " modeltype," + " ispublicbody," + " goodsid," + " goodscode," + " goodsname," + " userid," + " groutingdailyid," + " groutingdailydetailid," + " groutingdate," + " groutinglineid," + " groutinglinecode," + " groutinglinename," + " gmouldtypeid," + " canmanytimes," + " groutinglinedetailid," + " groutingmouldcode," + " mouldcode," + " accountid," + " createuserid," + " updateuserid,GoodsLevelTypeID," + " GroutingUserID," + " GroutingUserCode," + " GroutingNum," + " SpecialRepairflag," + " FlowProcedureID," + " FlowProcedureTime," + " ProcedureID," + " ProcedureTime," + " ProductionDataID,logoid" + " ) values (" + " :barcode," + " :productionlineid," + " :productionlinecode," + " :productionlinename," + " :procedureModel," + " :modelType," + " :isPublicBody," + " :goodsid," + " :goodscode," + " :goodsname," + " :userID," + " :groutingdailyid," + " :groutingdailydetailid," + " :groutingdate," + " :groutinglineid," + " :groutinglinecode," + " :groutinglinename," + " :gmouldtypeid," + " :canmanytimes," + " :groutinglinedetailid," + " :groutingmouldcode," + " :mouldcode," + " :accountID," + " :createUserID," + " :updateUserID," + " null," + " :groutinguserid," + " :groutingusercode," + " :groutingnum," + " :specialRepairflag," + " :flowProcedureID," + " sysdate," + " :procedureID," + " sysdate," + " :productionDataID,:logoid" + " ) "; #endregion paras = new OracleParameter[] { new OracleParameter(":procedureModel",inProduction.ProcedureModel), new OracleParameter(":modelType",inProduction.ModelType), new OracleParameter(":isPublicBody",inProduction.IsPublicBody), new OracleParameter(":userID",inProduction.UserID), new OracleParameter(":accountID",sUserInfo.AccountID), new OracleParameter(":createUserID",sUserInfo.UserID), new OracleParameter(":updateUserID",sUserInfo.UserID), new OracleParameter(":barcode",inProduction.BarCode), new OracleParameter(":specialRepairflag",inProduction.SpecialRepairflag), new OracleParameter(":productionlineid",ProductionLineID),//---开始赋值 new OracleParameter(":productionlinecode",ProductionLineCode), new OracleParameter(":productionlinename",ProductionLineName), new OracleParameter(":goodsid",goodsid), new OracleParameter(":goodscode",goodsCode), new OracleParameter(":goodsname",goodsName), new OracleParameter(":groutingdailyid",groutingDailyID), new OracleParameter(":groutingdailydetailid",groutingdailydetailid), new OracleParameter(":groutingdate",groutingdate), new OracleParameter(":groutinglineid",groutinglineid), new OracleParameter(":groutinglinecode",groutingLineCode), new OracleParameter(":groutinglinename",groutingLineName), new OracleParameter(":gmouldtypeid",gMouldTypeID), new OracleParameter(":canmanytimes",canManyTimes), new OracleParameter(":groutinglinedetailid",groutingLineDetailID), new OracleParameter(":groutingmouldcode",groutingmouldcode), new OracleParameter(":mouldcode",mouldCode), new OracleParameter(":groutinguserid",groutingUserID), new OracleParameter(":groutingusercode",groutingUserCode), new OracleParameter(":groutingnum",groutingNum), new OracleParameter(":flowProcedureID",inProduction.FlowProcedureID), new OracleParameter(":procedureID",inProduction.FlowProcedureID), new OracleParameter(":productionDataID",inProduction.ProductionDataID), new OracleParameter(":logoid",LogoID), }; int result = oracleTrConn.ExecuteNonQuery(sql, paras); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } //交坯后,更新用过条码 2015/7/14 string updateUsedBarCode = "update TP_PM_USEDBARCODE set barcodestatus=3 where barcode='" + inProduction.BarCode + "'"; oracleTrConn.ExecuteNonQuery(updateUsedBarCode); //交坯后,更新用过条码 end } // 保存成功返回null return null; } /// /// 根据最大生产数据ID,获取窑车窑炉等信息 /// /// /// /// /// private static DataSet GetFinishCheckKilnCarInfo(IDBTransaction oracleTrConn, string barcode, SUserInfo sUserInfo) { string sql = @"select KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, to_char(KilnCarBatchNo) as KilnCarBatchNo, KilnCarPosition from tp_pm_inproduction where barcode=:barcode union select KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, to_char(KilnCarBatchNo) as KilnCarBatchNo, KilnCarPosition from TP_PM_InProductionTrash where barcode=:barcode "; try { IDataParameter[] paras = new OracleParameter[] { new OracleParameter(":barcode", OracleDbType.Varchar2, barcode, ParameterDirection.Input), }; DataSet returnDs = oracleTrConn.GetSqlResultToDs(sql, paras); if (returnDs != null && returnDs.Tables.Count > Constant.INT_IS_ZERO && returnDs.Tables[0].Rows.Count > Constant.INT_IS_ZERO) { return returnDs; } else { return null; } } catch (Exception ex) { throw ex; } } /// /// 根据最大生产数据ID,获取窑车窑炉等信息 /// /// /// /// /// private static DataSet GetKilnCarInfo(IDBTransaction oracleTrConn, string barcode, SUserInfo sUserInfo) { // string sql = @"select * from tp_pm_productiondata where Productiondataid= // ( // select nvl(max(Productiondataid),0) Productiondataid from tp_pm_productiondata where barcode=:barcode // )"; // string sql = @"select // KilnID, // KilnCode, // KilnName, // KilnCarID, // KilnCarCode, // KilnCarName, // to_char(KilnCarBatchNo) as KilnCarBatchNo, // KilnCarPosition // from tp_pm_inproduction where barcode=:barcode // union // select // KilnID, // KilnCode, // KilnName, // KilnCarID, // KilnCarCode, // KilnCarName, // to_char(KilnCarBatchNo) as KilnCarBatchNo, // KilnCarPosition // from TP_PM_InProductionTrash where barcode=:barcode //"; string sql = @"select KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, to_char(KilnCarBatchNo) as KilnCarBatchNo, KilnCarPosition from tp_pm_inproduction where barcode=:barcode "; try { IDataParameter[] paras = new OracleParameter[] { new OracleParameter(":barcode", OracleDbType.Varchar2, barcode, ParameterDirection.Input), }; DataSet returnDs = oracleTrConn.GetSqlResultToDs(sql, paras); if (returnDs != null && returnDs.Tables.Count > Constant.INT_IS_ZERO && returnDs.Tables[0].Rows.Count > Constant.INT_IS_ZERO) { return returnDs; } else { return null; } } catch (Exception ex) { throw ex; } } /// /// 修改在产数据 /// /// 连接对象 /// 在产数据实体类 /// 用户基本信息 /// string /// /// 陈冰 2014.09.18 新建 /// private static string UpdateInProduction(IDBTransaction oracleTrConn, InProductionEntity inProduction, SUserInfo sUserInfo) { List paras = new List(); //paras.Add(new OracleParameter(":completeProcedureID", inProduction.CompleteProcedureID)); paras.Add(new OracleParameter(":procedureModel", inProduction.ProcedureModel)); paras.Add(new OracleParameter(":modelType", inProduction.ModelType)); paras.Add(new OracleParameter(":defectFlag", inProduction.DefectFlag)); paras.Add(new OracleParameter(":reworkProcedureID", inProduction.ReworkProcedureID)); paras.Add(new OracleParameter(":flowprocedureid", inProduction.FlowProcedureID)); paras.Add(new OracleParameter(":procedureID", inProduction.ProcedureID)); paras.Add(new OracleParameter(":productionDataID", inProduction.ProductionDataID)); #region SQL string sql = " update TP_PM_InProduction " //+ " set CompleteProcedureID = :completeProcedureID," + "set ProcedureModel = :procedureModel," + " ModelType = :modelType," + " DefectFlag = :defectFlag," + " flowprocedureid = :flowprocedureid," + " flowproceduretime = sysdate," + " procedureID = :procedureID," + " procedureTime = sysdate," + " productionDataID = :productionDataID," // + " GoodsLevelTypeID = :GoodsLevelTypeID," + " ReworkProcedureID = :reworkProcedureID,"; #region 只有交坯工序是才传值更改公坯字段 if (inProduction.IsPublicBody != null) { sql = sql + " IsPublicBody = :isPublicBody,"; paras.Add(new OracleParameter(":isPublicBody", inProduction.IsPublicBody)); } #endregion #region 只有走特定返工工序时才更改重烧字段 if (inProduction.IsReFire != null) { sql = sql + " IsReFire = :isReFire,"; paras.Add(new OracleParameter(":isReFire", inProduction.IsReFire)); } #endregion #region 只有成检时才更新产品分级字段 //if (inProduction.GoodsGrade != null) //{ // sql = sql + " GoodsGrade = :goodsGrade,"; // paras.Add(new OracleParameter(":goodsGrade", inProduction.GoodsGrade)); //} if (inProduction.GoodsLevelID != null) { sql = sql + " GoodsLevelID = :GoodsLevelID,"; paras.Add(new OracleParameter(":GoodsLevelID", inProduction.GoodsLevelID)); } if (inProduction.GoodsLevelTypeID != null) { sql = sql + " GoodsLevelTypeID = :GoodsLevelTypeID,"; paras.Add(new OracleParameter(":GoodsLevelTypeID", inProduction.GoodsLevelTypeID)); } #region 更新窑炉窑车属性 if (inProduction.ModelType == 1 || inProduction.ModelType == 2 || inProduction.ModelType == 3 || inProduction.ModelType == 4 || inProduction.ModelType == 6) { sql = sql + " KilnID = :KilnID,"; paras.Add(new OracleParameter(":KilnID", inProduction.KilnID)); sql = sql + " KilnCode = :KilnCode,"; paras.Add(new OracleParameter(":KilnCode", inProduction.KilnCode)); sql = sql + " KilnName = :KilnName,"; paras.Add(new OracleParameter(":KilnName", inProduction.KilnName)); sql = sql + " KilnCarID = :KilnCarID,"; paras.Add(new OracleParameter(":KilnCarID", inProduction.KilnCarID)); sql = sql + " KilnCarCode = :KilnCarCode,"; paras.Add(new OracleParameter(":KilnCarCode", inProduction.KilnCarCode)); sql = sql + " KilnCarName = :KilnCarName,"; paras.Add(new OracleParameter(":KilnCarName", inProduction.KilnCarName)); sql = sql + " KilnCarBatchNo = :KilnCarBatchNo,"; paras.Add(new OracleParameter(":KilnCarBatchNo", inProduction.KilnCarBatchNo)); sql = sql + " KilnCarPosition = :KilnCarPosition,"; paras.Add(new OracleParameter(":KilnCarPosition", inProduction.KilnCarPosition)); } else { // ////////DataSet ds = GetKilnCarInfo(oracleTrConn, inProduction.BarCode, sUserInfo); ////////if (ds != null) ////////{ //////// if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息 //////// { //////// sql = sql + " KilnID = :KilnID,"; //////// paras.Add(new OracleParameter(":KilnID", Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]))); //////// sql = sql + " KilnCode = :KilnCode,"; //////// paras.Add(new OracleParameter(":KilnCode", ds.Tables[0].Rows[0]["KilnCode"].ToString())); //////// sql = sql + " KilnName = :KilnName,"; //////// paras.Add(new OracleParameter(":KilnName", ds.Tables[0].Rows[0]["KilnName"].ToString())); //////// sql = sql + " KilnCarID = :KilnCarID,"; //////// paras.Add(new OracleParameter(":KilnCarID", Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]))); //////// sql = sql + " KilnCarCode = :KilnCarCode,"; //////// paras.Add(new OracleParameter(":KilnCarCode", ds.Tables[0].Rows[0]["KilnCarCode"].ToString())); //////// sql = sql + " KilnCarName = :KilnCarName,"; //////// paras.Add(new OracleParameter(":KilnCarName", ds.Tables[0].Rows[0]["KilnCarName"].ToString())); //////// sql = sql + " KilnCarBatchNo = :KilnCarBatchNo,"; //////// paras.Add(new OracleParameter(":KilnCarBatchNo", ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString())); //////// sql = sql + " KilnCarPosition = :KilnCarPosition,"; //////// paras.Add(new OracleParameter(":KilnCarPosition", Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]))); //////// } ////////} } #endregion #endregion #region 更新在产商标 if (inProduction.LogoID != null) { sql = sql + " LogoID = :LogoID,"; paras.Add(new OracleParameter(":LogoID", inProduction.LogoID)); } #endregion sql = sql + " UserID = :userID," + " UpdateUserID = :updateUserID" + " where Barcode = :barCode"; #endregion paras.Add(new OracleParameter(":userID", inProduction.UserID)); paras.Add(new OracleParameter(":updateUserID", sUserInfo.UserID)); paras.Add(new OracleParameter(":barCode", inProduction.BarCode)); foreach (var para in paras) { if (para.Value + "" == "") { para.Value = DBNull.Value; } } int result = oracleTrConn.ExecuteNonQuery(sql, paras.ToArray()); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 保存成功返回null return null; } /// /// 校验条码有效 /// /// 连接对象 /// 工序ID /// 条码 /// 返回的产品ID /// 返回的产品Code /// 返回的产品名称 /// 返回的注浆者ID /// string /// /// 陈冰 2014.09.18 新建 /// private static string CheckBarcode(IDBTransaction oracleTrConn, int procedureID, string barcode, out int goodsID, out string goodsCode, out string goodsName, out string groutingUserCode, SUserInfo sUserInfo ) { try { OracleParameter[] paras = new OracleParameter[]{ new OracleParameter("in_procedureid",OracleDbType.Int32,procedureID,ParameterDirection.Input), new OracleParameter("in_barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input), new OracleParameter("out_errMsg",OracleDbType.Varchar2,2000,"",ParameterDirection.Output), new OracleParameter("out_goodsID",OracleDbType.Int32,ParameterDirection.Output), new OracleParameter("out_goodsCode",OracleDbType.Varchar2,50,"",ParameterDirection.Output), new OracleParameter("out_goodsName",OracleDbType.Varchar2,50,"",ParameterDirection.Output), new OracleParameter("out_groutingUserCode",OracleDbType.NVarchar2,50,null,ParameterDirection.Output), new OracleParameter("out_errMsg_Status",OracleDbType.Varchar2,50,"",ParameterDirection.Output), }; oracleTrConn.ExecStoredProcedure("PRO_PM_CheckBarcode", paras); if (!"null".Equals(paras[3].Value + "")) { goodsID = Convert.ToInt32(paras[3].Value + ""); } else { goodsID = 0; } goodsCode = paras[4].Value + ""; goodsName = paras[5].Value + ""; if (!"null".Equals(paras[6].Value + "")) { groutingUserCode = paras[6].Value + ""; } else { groutingUserCode = null; } if ("null".Equals(paras[2].Value + "")) { return null; } return paras[2].Value.ToString().Replace("\\n\\r", "\n\r"); } catch (Exception ex) { throw ex; } } /// /// 查询工序信息 /// /// 连接对象 /// 工序ID /// 工序实体 private static ProcedureEntity GetProcedurByID(IDBTransaction oracleTrConn, int procedureID) { ProcedureEntity procedureEntity = new ProcedureEntity(); string procsql = "pro_pm_searchProcedurbyID"; try { IDataParameter[] paras = new OracleParameter[] { new OracleParameter("in_procedureID", OracleDbType.Int32, procedureID, ParameterDirection.Input), new OracleParameter("out_result", OracleDbType.RefCursor, ParameterDirection.Output) }; DataSet returnDs = oracleTrConn.ExecStoredProcedure(procsql, paras); if (returnDs != null && returnDs.Tables.Count > Constant.INT_IS_ZERO && returnDs.Tables[0].Rows.Count > Constant.INT_IS_ZERO) { DataRow row = returnDs.Tables[0].Rows[0]; // 转实体 procedureEntity = DataConvert.DataRowConvertToObject(row); return procedureEntity; } else { return null; } } catch (Exception ex) { throw ex; } } #endregion #region 检验 /// /// 保存条码信息 /// /// 工序ID /// 生产数据集 /// 用户基本信息 /// string public static string AddCheckBarcode(int procedureID, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo) { string errMsg = ""; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { oracleTrConn.Connect(); #region 查询工序信息 ProcedureEntity procedure = GetProcedurByID(oracleTrConn, procedureID); #endregion #region 标准检验(半成品) if (procedure.ModelType == (int)Constant.ProcedureModelType.Normal) { errMsg = AddNormalCheck(oracleTrConn, procedure, productionDataEntitys, sUserInfo); } #endregion #region 成品检验 else if (procedure.ModelType == (int)Constant.ProcedureModelType.QualityStatistics) { errMsg = AddFinishCheckPDA(oracleTrConn, procedure, productionDataEntitys, sUserInfo); } #endregion #region 入窑前检验 else if (procedure.ModelType == (int)Constant.ProcedureModelType.IntoKilnCheck) { errMsg = AddIntoKilnCheck(oracleTrConn, procedure, productionDataEntitys, sUserInfo); } #endregion // 没有错误 提交事务 if (string.IsNullOrEmpty(errMsg)) { oracleTrConn.Commit(); } } catch (Exception ex) { oracleTrConn.Rollback(); throw ex; } finally { // 释放资源 if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Disconnect(); } } return errMsg; } /// /// 入窑前检验 /// /// 连接对象 /// 工序 /// 生产数据集 /// 用户基本信息 /// string private static string AddIntoKilnCheck(IDBTransaction oracleTrConn, ProcedureEntity procedure, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo) { string errMsg = ""; // 获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); // 本批采集的批次号 string centralizedBatchNo = System.Guid.NewGuid().ToString(); #region 查询产品分级 string sqlGoodsLevel = "select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where AccountID=:accountID and ValueFlag=1"; DataTable goodsLevelTable = oracleTrConn.GetSqlResultToDt(sqlGoodsLevel, new OracleParameter[] { new OracleParameter(":accountID", sUserInfo.AccountID) }); #endregion foreach (ProductionDataEntity productionData in productionDataEntitys) { if (string.IsNullOrEmpty(productionData.Barcode)) { throw new Exception("传入的条码号为空"); } if (productionData.ProductionDataID != 0) { errMsg = DeleteSubstandardToSubstandardByID(oracleTrConn, productionData.ProductionDataID, productionData.Barcode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } // 删除报废条码 string updateScrapSql = @"update tp_pm_scrapproduct set ValueFlag=0 where tp_pm_scrapproduct.barcode=:barcode"; OracleParameter[] ScrapProductparas = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input), }; oracleTrConn.ExecuteNonQuery(updateScrapSql, ScrapProductparas); string sqlInsInProdString = @"insert into TP_PM_InProduction(BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid,IsReworkFlag,SemiCheckID) select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, :UpdateUserID, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID , FlowProcedureTime,ProcedureID,sysdate,ProductionDataID,logoid,IsReworkFlag,SemiCheckID from TP_PM_InProductionTrash where barcode=:barcode "; OracleParameter[] InProductparas = new OracleParameter[]{ new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input), }; oracleTrConn.ExecuteNonQuery(sqlInsInProdString, InProductparas); //删除回收站中的条码 string sqlDelInProductTrashString = "delete from TP_PM_InProductionTrash where barcode=:barcode "; OracleParameter[] TrashProductparas = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input) }; oracleTrConn.ExecuteNonQuery(sqlDelInProductTrashString, TrashProductparas); } int goodsID = Constant.INT_IS_ZERO; string goodsCode = string.Empty; string goodsName = string.Empty; // 注浆者工号 string groutingUserCode = string.Empty; #region 校验条码有效性 errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, productionData.Barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { if (productionData.ProductionDataID == 0) return errMsg; } #endregion #region 获得产品分级ID DataRow[] dr = goodsLevelTable.Select("GoodsLevelTypeID=" + productionData.GoodsLevelTypeID); // 获得产品分级ID productionData.GoodsLevelID = Convert.ToInt32(dr[0]["GoodsLevelID"]); #endregion // 查询新插入的生产数据ID string sql = "select SEQ_PM_ProductionData_ID.nextval from dual"; string idStr = oracleTrConn.GetSqlResultToStr(sql); int productionDataID = 0; if (!string.IsNullOrEmpty(idStr)) { productionDataID = int.Parse(idStr); } else { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } int? ClassesSettingID = null;//班次配置ID #region 添加生产者数据 errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo, ref ClassesSettingID); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 添加生产数据 #region 属性赋值 productionData.ClassesSettingID = ClassesSettingID; productionData.ProductionDataID = Convert.ToInt32(idStr); productionData.CentralizedBatchNo = centralizedBatchNo; productionData.ProductionLineID = procedure.ProductionLineID; productionData.ProductionLineCode = procedure.ProductionlineCode; productionData.ProductionLineName = procedure.ProductionlineName; productionData.ProcedureID = procedure.ProcedureID; productionData.ProcedureCode = procedure.ProcedureCode; productionData.ProcedureName = procedure.ProcedureName; productionData.ProcedureModel = procedure.ProcedureModel; productionData.ModelType = procedure.ModelType; productionData.NodeType = procedure.NodeType; productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, productionData.Barcode); productionData.IsReFire = (int)Constant.ReFireFlag.No; productionData.GoodsGrade = (int)Constant.GoodsGrade.Good; productionData.OrganizationID = procedure.OrganizationID; productionData.GoodsID = goodsID; productionData.GoodsCode = goodsCode; productionData.GoodsName = goodsName; productionData.GoodsLevelID = productionData.GoodsLevelID; productionData.GoodsLevelTypeID = productionData.GoodsLevelTypeID; //如果报废给此产品最状态赋值 wangxin 2015/4/1 因为删除掉了生产数据表中的产品最终状态 ////if (productionData.ProductionDefects != null) ////{ //// foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects) //// { //// if ((string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag) == "1") //// { //// productionData.GoodsEnding = productionData.GoodsLevelTypeID.ToString(); //// break; //// } //// } ////} ////if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Waste) ////{ //// productionData.GoodsEnding = Constant.GoodsLevelType.Waste.GetHashCode().ToString(); ////} ////// string sqlReFire = @"select ////// isrefire ////// from tp_pm_inproduction where barcode=:barcode ////// "; ////// OracleParameter[] ReFireparas = new OracleParameter[] { ////// new OracleParameter(":barcode",productionData.Barcode), ////// }; ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas); ////// //DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire); ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0) ////// { ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0) ////// { ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]); ////// } ////// } #endregion string OutSpecialRepairflag = "0";//干补标识 //errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); errMsg = AddProductionDataWaster(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion //#region 添加生产者数据 //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} //#endregion #region 条码有缺陷 // 废品标识 bool scrapFlag = false; // 存在缺陷 插入缺陷表 if (productionData.ProductionDefects != null) { foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects) { #region 保存缺陷 productionDefect.ProductionDataID = productionDataID; productionDefect.BarCode = productionData.Barcode; productionDefect.ProductionLineID = procedure.ProductionLineID; productionDefect.ProductionLineCode = procedure.ProductionlineCode; productionDefect.ProductionLineName = procedure.ProductionlineName; productionDefect.ProcedureID = procedure.ProcedureID; productionDefect.ProcedureCode = procedure.ProcedureCode; productionDefect.ProcedureName = procedure.ProcedureName; productionDefect.UserID = productionData.UserID; productionDefect.UserCode = productionData.UserCode; productionDefect.UserName = productionData.UserName; productionDefect.GoodsID = productionData.GoodsID; productionDefect.GoodsCode = productionData.GoodsCode; productionDefect.GoodsName = productionData.GoodsName; productionData.Remarks = productionData.Remarks; productionDefect.ScrapResponFlag = string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag; // 保存缺陷 errMsg = AddDefect(oracleTrConn, productionDefect, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 缺陷列表中只有一个报废工序 添加废弃产品 删除在产产品数据 if (!scrapFlag && productionDefect.ScrapResponFlag == "1") { scrapFlag = true; #region 添加废弃产品 删除在产产品数据 #region 添加废弃产品 ScrapProductEntity scrapProduct = new ScrapProductEntity(); #region 属性赋值 scrapProduct.BarCode = productionData.Barcode; scrapProduct.ScrapType = Constant.ScrapType.Waste.GetHashCode(); if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { scrapProduct.ResponType = Constant.ScrapResponType.NoPerson.GetHashCode(); } else { scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode(); } scrapProduct.ScrapDate = accountDate; scrapProduct.Rreason = Constant.SCRAPTYPE_WASTE; scrapProduct.Remarks = productionDefect.Remarks; scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode(); scrapProduct.Auditor = sUserInfo.UserID; scrapProduct.AuditlDate = accountDate; scrapProduct.AccountDate = accountDate; scrapProduct.GoodsLevelID = productionData.GoodsLevelID; scrapProduct.GoodsLevelTypeID = productionData.GoodsLevelTypeID; scrapProduct.IsPublicBody = productionData.IsPublicBody; string sqlScrapProduct = "select SEQ_PM_ScrapProduct_ID.nextval from dual"; string idStrScrapProduct = oracleTrConn.GetSqlResultToStr(sqlScrapProduct); scrapProduct.ScrapProductID = Convert.ToInt32(idStrScrapProduct); scrapProduct.ScrapType = 1; #endregion // 保存报废 errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo); // 保存失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 添加责任工序 // 不是开始工序时。需要添加责任工序 if (procedure.NodeType != Constant.ProcedureNodeType.Begin.GetHashCode()) { //string sqlScrapProduct = "select SEQ_PM_ScrapProduct_ID.Currval from dual"; //string idStrScrapProduct = oracleTrConn.GetSqlResultToStr(sqlScrapProduct); ResponProcedureEntity responProce = new ResponProcedureEntity(); #region 属性赋值 responProce.BarCode = productionData.Barcode; responProce.ProductionDataID = productionDataID; responProce.ProductionLineID = productionDefect.ProductionLineID; responProce.ProductionLineCode = productionDefect.ProductionLineCode; responProce.ProductionLineName = productionDefect.ProductionLineName; responProce.ProcedureID = productionDefect.DefectProcedureID; responProce.ProcedureCode = productionDefect.DefectProcedureCode; responProce.ProcedureName = productionDefect.DefectProcedureName; responProce.UserID = productionDefect.DefectUserID; responProce.UserCode = productionDefect.DefectUserCode; responProce.UserName = productionDefect.DefectUserName; responProce.Remarks = productionDefect.Remarks; responProce.ScrapProductID = Convert.ToInt32(idStrScrapProduct); #endregion // 保存责任工序 errMsg = AddResponProcedure(oracleTrConn, responProce, productionDefect, sUserInfo); // 保存失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } } #endregion #region 删除在产产品数据 InProductionEntity delInProductionEntity = new InProductionEntity(); delInProductionEntity.BarCode = productionData.Barcode; delInProductionEntity.CompleteProcedureID = productionData.ProcedureID; // 执行删除 在产数据 errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, false, sUserInfo); // 执行失败 // if (!string.IsNullOrEmpty(errMsg)) 注释日期2015-12-28 // { // return errMsg; // } #endregion #endregion } #endregion } } #endregion // 条码有缺陷或者报废 //wangxin 20150414 //if (scrapFlag || productionData.GoodsLevelTypeID == Constant.GoodsLevelType.Defect.GetHashCode()) //{ #region 有缺陷 删除条码对应窑车产品 if (productionData.DefectFlag == Constant.GoodsLevelType.Defect.GetHashCode()) { errMsg = DeleteKilnCarGoods(oracleTrConn, productionData.Barcode); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } } #endregion //} //wangxin 20150414 end // 条码没有报废 if (!scrapFlag) { #region 修改在产产品数据的当前工序 InProductionEntity inProductionEntity = new InProductionEntity(); inProductionEntity.BarCode = productionData.Barcode; //流程工序 inProductionEntity.FlowProcedureID = procedure.ProcedureID; // 当前工序 //inProductionEntity.CompleteProcedureID = procedure.ProcedureID; inProductionEntity.ProcedureID = procedure.ProcedureID; // 生产数据ID inProductionEntity.ProductionDataID = productionDataID; // 工序模型 inProductionEntity.ProcedureModel = procedure.ProcedureModel; // 工序类别 inProductionEntity.ModelType = procedure.ModelType; // 生产工号 inProductionEntity.UserID = productionData.UserID; // 缺陷标识 inProductionEntity.DefectFlag = productionData.DefectFlag; // 返工工序ID inProductionEntity.ReworkProcedureID = productionData.ReworkProcedureID; inProductionEntity.GoodsLevelID = productionData.GoodsLevelID; inProductionEntity.GoodsLevelTypeID = productionData.GoodsLevelTypeID; inProductionEntity.IsPublicBody = productionData.IsPublicBody; // 执行修改 errMsg = UpdateInProduction(oracleTrConn, inProductionEntity, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } } return errMsg; } /// /// 删除窑车产品 /// /// 数据连接 /// 产品条码 /// string private static string DeleteKilnCarGoods(IDBTransaction oracleTrConn, string barcode) { string sql = "delete TP_PM_KilnCarGoods where BarCode = :barcode"; OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":barcode", barcode) }; int result = oracleTrConn.ExecuteNonQuery(sql, paras); // 保存失败 if (result != Constant.INT_IS_ONE) { //return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } return null; } /// /// 添加成品编辑 /// /// 数据连接 /// 工序对象 /// 生产数据集 /// 用户基本信息 /// string //private static string AddFinishCheck(IDBTransaction oracleTrConn, ProcedureEntity procedure, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo) //{ // string errMsg = ""; // // 获得账务日期 // DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); // // 本批采集的批次号 // string centralizedBatchNo = System.Guid.NewGuid().ToString(); // foreach (ProductionDataEntity productionData in productionDataEntitys) // { // if (string.IsNullOrEmpty(productionData.Barcode)) // { // throw new Exception("传入的条码号为空"); // } // int goodsID = Constant.INT_IS_ZERO; // string goodsCode = string.Empty; // string goodsName = string.Empty; // // 注浆者工号 // string groutingUserCode = string.Empty; // // 次品标识 // bool substandardFlag = false; // #region 校验条码有效性 // errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, productionData.Barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo); // if (!string.IsNullOrEmpty(errMsg)) // { // if (productionData.ProductionDataID == 0) // return errMsg; // } // #endregion // #region 添加生产数据 // #region 属性赋值 // productionData.CentralizedBatchNo = centralizedBatchNo; // productionData.ProductionLineID = procedure.ProductionLineID; // productionData.ProductionLineCode = procedure.ProductionlineCode; // productionData.ProductionLineName = procedure.ProductionlineName; // productionData.CompleteProcedureID = procedure.ProcedureID; // productionData.ProcedureCode = procedure.ProcedureCode; // productionData.ProcedureName = procedure.ProcedureName; // productionData.ProcedureModel = procedure.ProcedureModel; // productionData.ModelType = procedure.ModelType; // productionData.IsPublicBody = (int)Constant.PublicBodyFlag.No; // // 重烧 // if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.ReFire) // { // //productionData.GoodsLevelID = null; // productionData.IsReFire = (int)Constant.ReFireFlag.No; // } // // 次品 // else if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Reject) // { // //productionData.GoodsLevelID = null; // substandardFlag = true; // } // // 查询新插入的生产数据ID // if (productionData.GoodsLevelTypeID != (int)Constant.GoodsLevelType.ReFire) // { // //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态 // //string sqlReFire = "select * from tp_PM_ProductionData where ProductionData=(select max(ProductionDataid) from ProductionData where barcode=" + productionData.Barcode + " and ProcedureID=" + productionData.ProcedureID + ")"; // string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')"; // DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire); // if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0) // { // productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]); // } // } // productionData.OrganizationID = procedure.OrganizationID; // productionData.GoodsID = goodsID; // productionData.GoodsCode = goodsCode; // productionData.GoodsName = goodsName; // productionData.GoodsLevelID = productionData.GoodsLevelID; // productionData.GoodsLevelTypeID = productionData.GoodsLevelTypeID; // //if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Reject) // //{ // // productionData.GoodsEnding = Constant.GoodsLevelType.Reject.GetHashCode().ToString(); // //} // #endregion // string OutSpecialRepairflag = "0";//干补标识 // errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); // if (!string.IsNullOrEmpty(errMsg)) // { // return errMsg; // } // // 查询新插入的生产数据ID // string sql = "select SEQ_PM_ProductionData_ID.Currval from dual"; // string idStr = oracleTrConn.GetSqlResultToStr(sql); // // 新插入的班次配置表ID // int productionDataID = 0; // if (!string.IsNullOrEmpty(idStr)) // { // productionDataID = int.Parse(idStr); // } // else // { // return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); // } // #endregion // #region 添加生产者数据 // int? ClassesSettingID = null;//班次配置ID // errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo, ref ClassesSettingID); // if (!string.IsNullOrEmpty(errMsg)) // { // return errMsg; // } // #endregion // #region 条码有缺陷 // #region 是次品 添加废弃产品 // if (substandardFlag) // { // #region 添加废弃产品 // ScrapProductEntity scrapProduct = new ScrapProductEntity(); // #region 属性赋值 // scrapProduct.BarCode = productionData.Barcode; // scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode(); // scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode(); // scrapProduct.ScrapDate = accountDate; // scrapProduct.Rreason = Constant.SCRAPTYPE_SUBSTANDARD; // scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode(); // scrapProduct.Auditor = sUserInfo.UserID; // scrapProduct.AuditlDate = accountDate; // scrapProduct.AccountDate = accountDate; // scrapProduct.GoodsLevelID = productionData.GoodsLevelID; // scrapProduct.GoodsLevelTypeID = productionData.GoodsLevelTypeID; // #endregion // // 保存报废 // errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo); // // 保存失败 // if (!string.IsNullOrEmpty(errMsg)) // { // return errMsg; // } // #endregion // } // #endregion // // 存在缺陷 插入缺陷表 // if (productionData.ProductionDefects != null) // { // foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects) // { // #region 保存缺陷 // productionDefect.ProductionDataID = productionDataID; // productionDefect.BarCode = productionData.Barcode; // productionDefect.ProductionLineID = procedure.ProductionLineID; // productionDefect.ProductionLineCode = procedure.ProductionlineCode; // productionDefect.ProductionLineName = procedure.ProductionlineName; // productionDefect.ProcedureID = procedure.ProcedureID; // productionDefect.ProcedureCode = procedure.ProcedureCode; // productionDefect.ProcedureName = procedure.ProcedureName; // productionDefect.UserID = productionData.UserID; // productionDefect.UserCode = productionData.UserCode; // productionDefect.UserName = productionData.UserName; // productionDefect.GoodsID = productionData.GoodsID; // productionDefect.GoodsCode = productionData.GoodsCode; // productionDefect.GoodsName = productionData.GoodsName; // productionData.Remarks = productionData.Remarks; // productionDefect.ScrapResponFlag // = string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag; // // 保存缺陷 // errMsg = AddDefect(oracleTrConn, productionDefect, sUserInfo); // if (!string.IsNullOrEmpty(errMsg)) // { // return errMsg; // } // #endregion // #region 是次品 添加废弃责任工序 // if (substandardFlag) // { // #region 添加责任工序 // ResponProcedureEntity responProce = new ResponProcedureEntity(); // // 查询新插入的废弃ID // string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.Currval from dual"; // string ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql); // #region 属性赋值 // responProce.BarCode = productionData.Barcode; // responProce.ProductionDataID = productionDataID; // responProce.ProductionLineID = productionDefect.ProductionLineID; // responProce.ProductionLineCode = productionDefect.ProductionLineCode; // responProce.ProductionLineName = productionDefect.ProductionLineName; // responProce.ProcedureID = productionDefect.DefectProcedureID; // responProce.ProcedureCode = productionDefect.DefectProcedureCode; // responProce.ProcedureName = productionDefect.DefectProcedureName; // responProce.UserID = productionDefect.DefectUserID; // responProce.UserCode = productionDefect.DefectUserCode; // responProce.UserName = productionDefect.DefectUserName; // responProce.Remarks = productionDefect.Remarks; // responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr); // #endregion // // 保存责任工序 // errMsg = AddResponProcedure(oracleTrConn, responProce, productionDefect, sUserInfo); // // 保存失败 // if (!string.IsNullOrEmpty(errMsg)) // { // return errMsg; // } // #endregion // } // #endregion // } // } // #endregion // #region 条码是次品 删除在产产品数据 // if (substandardFlag) // { // #region 删除在产产品数据 // InProductionEntity delInProductionEntity = new InProductionEntity(); // delInProductionEntity.BarCode = productionData.Barcode; // // 执行删除 在产数据 // errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, false, sUserInfo); // // 执行失败 // if (!string.IsNullOrEmpty(errMsg)) // { // return errMsg; // } // #endregion // } // #endregion // #region 条码不是次品 // if (!substandardFlag) // { // #region 中间工序/重烧 修改在产产品数据 // if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle // || productionData.IsReFire == Constant.GoodsGrade.ReFire.GetHashCode()) // { // #region 修改在产产品数据的当前工序 // InProductionEntity inProductionEntity = new InProductionEntity(); // inProductionEntity.BarCode = productionData.Barcode; // // 当前工序 // inProductionEntity.CompleteProcedureID = procedure.ProcedureID; // // 工序模型 // inProductionEntity.ProcedureModel = procedure.ProcedureModel; // // 工序类别 // inProductionEntity.ModelType = procedure.ModelType; // // 生产工号 // inProductionEntity.UserID = productionData.UserID; // // 重烧 // inProductionEntity.IsReFire = productionData.IsReFire; // // 缺陷 // inProductionEntity.DefectFlag = productionData.DefectFlag; // // 产品分级 // inProductionEntity.GoodsGrade = productionData.GoodsGrade; // // 返工工序ID // inProductionEntity.ReworkProcedureID = productionData.ReworkProcedureID; // inProductionEntity.GoodsLevelID = productionData.GoodsLevelID; // inProductionEntity.GoodsLevelTypeID = productionData.GoodsLevelTypeID; // // 执行修改 // errMsg = UpdateInProduction(oracleTrConn, inProductionEntity, sUserInfo); // // 执行失败 // if (!string.IsNullOrEmpty(errMsg)) // { // return errMsg; // } // #endregion // } // #endregion // #region 结束工序 添加成品数据 删除在产产品数据 // else if (procedure.NodeType == (int)Constant.ProcedureNodeType.End) // { // #region 添加成品数据 删除在产产品数据 // FinishedProductEntity finishedProduct = new FinishedProductEntity(); // finishedProduct.BarCode = productionData.Barcode; // errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo); // if (!string.IsNullOrEmpty(errMsg)) // { // return errMsg; // } // InProductionEntity delInProductionEntity = new InProductionEntity(); // delInProductionEntity.BarCode = productionData.Barcode; // // 执行删除 在产数据 // errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo); // // 执行失败 // if (!string.IsNullOrEmpty(errMsg)) // { // return errMsg; // } // #endregion // } // #endregion // } // #endregion // } // return errMsg; //} /// /// 保存标准检验 /// /// 连接对象 /// 工序信息 /// 生产数据集合 /// 用户基本信息 /// string private static string AddNormalCheck(IDBTransaction oracleTrConn, ProcedureEntity procedure, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo) { string errMsg = ""; // 获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); // 本批采集的批次号 string centralizedBatchNo = System.Guid.NewGuid().ToString(); string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo; #region 查询产品分级 string sqlGoodsLevel = "select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where AccountID=:accountID and ValueFlag=1"; DataTable goodsLevelTable = oracleTrConn.GetSqlResultToDt(sqlGoodsLevel, new OracleParameter[] { new OracleParameter(":accountID", sUserInfo.AccountID) }); #endregion foreach (ProductionDataEntity productionData in productionDataEntitys) { if (string.IsNullOrEmpty(productionData.Barcode)) { throw new Exception("传入的条码号为空"); } if (productionData.ProductionDataID != 0) { errMsg = DeleteSubstandardToSubstandardByID(oracleTrConn, productionData.ProductionDataID, productionData.Barcode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } // 删除报废条码 string updateScrapSql = @"update tp_pm_scrapproduct set ValueFlag=0 where tp_pm_scrapproduct.barcode=:barcode"; OracleParameter[] ScrapProductparas = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input), }; oracleTrConn.ExecuteNonQuery(updateScrapSql, ScrapProductparas); string sqlInsInProdString = @"insert into TP_PM_InProduction(BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid,IsReworkFlag,SemiCheckID) select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, :UpdateUserID, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID , FlowProcedureTime,ProcedureID,sysdate,ProductionDataID,logoid,IsReworkFlag,SemiCheckID from TP_PM_InProductionTrash where barcode=:barcode "; OracleParameter[] InProductparas = new OracleParameter[]{ new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input), }; oracleTrConn.ExecuteNonQuery(sqlInsInProdString, InProductparas); //删除回收站中的条码 string sqlDelInProductTrashString = "delete from TP_PM_InProductionTrash where barcode=:barcode "; OracleParameter[] TrashProductparas = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input) }; oracleTrConn.ExecuteNonQuery(sqlDelInProductTrashString, TrashProductparas); } int goodsID = Constant.INT_IS_ZERO; string goodsCode = string.Empty; string goodsName = string.Empty; // 注浆者工号 string groutingUserCode = string.Empty; #region 校验条码有效性 errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, productionData.Barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { if (productionData.ProductionDataID == 0) return errMsg; } #endregion // 查询新插入的生产数据ID string sql = "select SEQ_PM_ProductionData_ID.nextval from dual"; string idStr = oracleTrConn.GetSqlResultToStr(sql); int? ClassesSettingID = null;//班次配置ID // 新插入的班次配置表ID int productionDataID = 0; if (!string.IsNullOrEmpty(idStr)) { productionDataID = int.Parse(idStr); } else { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } #region 添加生产者数据 errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo, ref ClassesSettingID); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 添加生产数据 #region 属性赋值 productionData.ClassesSettingID = ClassesSettingID; productionData.ProductionDataID = Convert.ToInt32(idStr); productionData.CentralizedBatchNo = centralizedBatchNo; productionData.ProductionLineID = procedure.ProductionLineID; productionData.ProductionLineCode = procedure.ProductionlineCode; productionData.ProductionLineName = procedure.ProductionlineName; productionData.CompleteProcedureID = procedure.ProcedureID; productionData.ProcedureID = procedure.ProcedureID; productionData.ProcedureCode = procedure.ProcedureCode; productionData.ProcedureName = procedure.ProcedureName; productionData.ProcedureModel = procedure.ProcedureModel; productionData.ModelType = procedure.ModelType; productionData.NodeType = procedure.NodeType; productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, productionData.Barcode); productionData.IsReFire = (int)Constant.ReFireFlag.No; productionData.GoodsGrade = (int)Constant.GoodsGrade.Good; productionData.OrganizationID = procedure.OrganizationID; productionData.GoodsID = goodsID; productionData.GoodsCode = goodsCode; productionData.GoodsName = goodsName; productionData.GoodsLevelID = productionData.GoodsLevelID; productionData.GoodsLevelTypeID = productionData.GoodsLevelTypeID; ////////如果报废给此产品最状态赋值 //////if (productionData.ProductionDefects != null) //////{ ////// foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects) ////// { ////// if ((string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag) == "1") ////// { ////// productionData.GoodsEnding = productionData.GoodsLevelTypeID.ToString(); ////// break; ////// } ////// } //////} //////if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Waste) //////{ ////// productionData.GoodsEnding = Constant.GoodsLevelType.Waste.GetHashCode().ToString(); //////} ////// string sqlReFire = @"select ////// isrefire ////// from tp_pm_inproduction where barcode=:barcode ////// "; ////// OracleParameter[] ReFireparas = new OracleParameter[] { ////// new OracleParameter(":barcode",productionData.Barcode), ////// }; ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas); ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0) ////// { ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0) ////// { ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]); ////// } ////// } #endregion string OutSpecialRepairflag = "0";//干补标识 DataSet outDataSet = null; if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { errMsg = AddProductionDataDeliverMud(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, out outDataSet); } else { errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); } if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } if (productionData.ProductionDefects == null || productionData.ProductionDefects.Count == 0) { productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects; } #endregion #region 获得产品分级ID DataRow[] dr = goodsLevelTable.Select("GoodsLevelTypeID=" + productionData.GoodsLevelTypeID); // 获得产品分级ID productionData.GoodsLevelID = Convert.ToInt32(dr[0]["GoodsLevelID"]); #endregion #region 开始节点 if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { #region 添加在产产品数据 InProductionEntity addInProductionEntity = new InProductionEntity(); addInProductionEntity.ProductionDataID = productionData.ProductionDataID; addInProductionEntity.BarCode = productionData.Barcode; //流程工序 addInProductionEntity.FlowProcedureID = procedure.ProcedureID; // 当前工序 //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID; addInProductionEntity.ProcedureID = procedure.ProcedureID; //生产数据ID addInProductionEntity.ProductionDataID = productionDataID; // 工序模型 addInProductionEntity.ProcedureModel = procedure.ProcedureModel; // 工序类别 addInProductionEntity.ModelType = procedure.ModelType; // 正常坯 addInProductionEntity.IsPublicBody = (int)Constant.PublicBodyFlag.No; #endregion // 生产工号 addInProductionEntity.UserID = productionData.UserID; // 执行添加 errMsg = AddInProduction(oracleTrConn, addInProductionEntity, sUserInfo, outDataSet); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } } #endregion #region 条码有缺陷 // 废品标识 bool scrapFlag = false; // 存在缺陷 插入缺陷表 if (productionData.ProductionDefects != null) { foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects) { #region 保存缺陷 productionDefect.ProductionDataID = productionDataID; productionDefect.BarCode = productionData.Barcode; productionDefect.ProductionLineID = procedure.ProductionLineID; productionDefect.ProductionLineCode = procedure.ProductionlineCode; productionDefect.ProductionLineName = procedure.ProductionlineName; productionDefect.ProcedureID = procedure.ProcedureID; productionDefect.ProcedureCode = procedure.ProcedureCode; productionDefect.ProcedureName = procedure.ProcedureName; productionDefect.UserID = productionData.UserID; productionDefect.UserCode = productionData.UserCode; productionDefect.UserName = productionData.UserName; productionDefect.GoodsID = productionData.GoodsID; productionDefect.GoodsCode = productionData.GoodsCode; productionDefect.GoodsName = productionData.GoodsName; productionDefect.Remarks = productionData.Remarks; productionDefect.ScrapResponFlag = string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag; // 保存缺陷 errMsg = AddDefect(oracleTrConn, productionDefect, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 缺陷列表中只有一个报废工序 添加废弃产品 删除在产产品数据 if (!scrapFlag && productionDefect.ScrapResponFlag == "1") { scrapFlag = true; #region 添加废弃产品 删除在产产品数据 #region 添加废弃产品 ScrapProductEntity scrapProduct = new ScrapProductEntity(); #region 属性赋值 scrapProduct.BarCode = productionData.Barcode; scrapProduct.ScrapType = Constant.ScrapType.Waste.GetHashCode(); if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { scrapProduct.ResponType = Constant.ScrapResponType.NoPerson.GetHashCode(); } else { scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode(); } scrapProduct.ScrapDate = accountDate; scrapProduct.Rreason = Constant.SCRAPTYPE_WASTE; scrapProduct.Remarks = productionDefect.Remarks; scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode(); scrapProduct.Auditor = sUserInfo.UserID; scrapProduct.AuditlDate = accountDate; scrapProduct.AccountDate = accountDate; scrapProduct.GoodsLevelID = productionData.GoodsLevelID; scrapProduct.GoodsLevelTypeID = productionData.GoodsLevelTypeID; string sqlScrapProduct = "select SEQ_PM_ScrapProduct_ID.nextval from dual"; string idStrScrapProduct = oracleTrConn.GetSqlResultToStr(sqlScrapProduct); scrapProduct.ScrapProductID = Convert.ToInt32(idStrScrapProduct); scrapProduct.ScrapType = 1; scrapProduct.IsQualityStatistics = 1; scrapProduct.ProductionDataID = productionData.ProductionDataID; #endregion // 保存报废 errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo); // 保存失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 添加责任工序 // 不是开始工序时。需要添加责任工序 if (procedure.NodeType != Constant.ProcedureNodeType.Begin.GetHashCode()) { //string sqlScrapProduct = "select SEQ_PM_ScrapProduct_ID.Currval from dual"; //string idStrScrapProduct = oracleTrConn.GetSqlResultToStr(sqlScrapProduct); ResponProcedureEntity responProce = new ResponProcedureEntity(); #region 属性赋值 responProce.BarCode = productionData.Barcode; responProce.ProductionDataID = productionDataID; responProce.ProductionLineID = productionDefect.ProductionLineID; responProce.ProductionLineCode = productionDefect.ProductionLineCode; responProce.ProductionLineName = productionDefect.ProductionLineName; responProce.ProcedureID = productionDefect.DefectProcedureID; responProce.ProcedureCode = productionDefect.DefectProcedureCode; responProce.ProcedureName = productionDefect.DefectProcedureName; responProce.UserID = productionDefect.DefectUserID; responProce.UserCode = productionDefect.DefectUserCode; responProce.UserName = productionDefect.DefectUserName; responProce.Remarks = productionDefect.Remarks; responProce.ScrapProductID = Convert.ToInt32(idStrScrapProduct); #endregion // 保存责任工序 errMsg = AddResponProcedure(oracleTrConn, responProce, productionDefect, sUserInfo); // 保存失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } } #endregion #region 删除在产产品数据 InProductionEntity delInProductionEntity = new InProductionEntity(); delInProductionEntity.BarCode = productionData.Barcode; delInProductionEntity.CompleteProcedureID = productionData.ProcedureID; // 执行删除 在产数据 errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, false, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #endregion } #endregion } } #endregion #region 条码没有报废 if (!scrapFlag) { #region 检验出缺陷 并且不是废品 修改在产产品数据 //if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle // || productionData.DefectFlag == Constant.DefectFlag.Yes.GetHashCode()) if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle || procedure.NodeType == (int)Constant.ProcedureNodeType.Begin || productionData.GoodsLevelTypeID == Constant.GoodsLevelType.Defect.GetHashCode()) { #region 修改在产产品数据的当前工序 InProductionEntity inProductionEntity = new InProductionEntity(); inProductionEntity.ProductionDataID = Convert.ToInt32(idStr); inProductionEntity.BarCode = productionData.Barcode; // 当前工序 inProductionEntity.ProcedureID = procedure.ProcedureID; inProductionEntity.FlowProcedureID = procedure.ProcedureID; // 工序模型 inProductionEntity.ProcedureModel = procedure.ProcedureModel; // 工序类别 inProductionEntity.ModelType = procedure.ModelType; // 生产工号 inProductionEntity.UserID = productionData.UserID; // 缺陷标识 inProductionEntity.DefectFlag = productionData.DefectFlag; // 返工工序ID inProductionEntity.ReworkProcedureID = productionData.ReworkProcedureID; inProductionEntity.GoodsLevelTypeID = productionData.GoodsLevelTypeID; inProductionEntity.GoodsLevelID = productionData.GoodsLevelID; // 执行修改 errMsg = UpdateInProduction(oracleTrConn, inProductionEntity, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion #region 结束工序、没有缺陷 添加成品数据 删除在产产品数据 //else if (procedure.NodeType == (int)Constant.ProcedureNodeType.End // && productionData.DefectFlag == Constant.DefectFlag.No.GetHashCode()) else if (procedure.NodeType == (int)Constant.ProcedureNodeType.End && productionData.GoodsLevelTypeID == Constant.GoodsLevelType.NoDefects.GetHashCode()) { #region 添加成品数据 删除在产产品数据 FinishedProductEntity finishedProduct = new FinishedProductEntity(); finishedProduct.BarCode = productionData.Barcode; errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } InProductionEntity delInProductionEntity = new InProductionEntity(); delInProductionEntity.BarCode = productionData.Barcode; // 执行删除 在产数据 errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion } #endregion } return errMsg; } ///// ///// 报废更新产品数据最终状态 ///// ///// 连接对象 ///// 产品条码 ///// 用记基本信息 ///// string ///// ///// 王鑫 2015.01.07 新建 ///// //private static string UpdateProductionDataGoodsEnding(IDBTransaction oracleTrConn, int productionDataID, int? goodsEnding, SUserInfo sUserInfo) //{ // string sql = "update TP_PM_ProductionData set GoodsEnding=:goodsEnding where ProductionDataID = :productionDataID and AccountID=:accountid"; // OracleParameter[] paras = new OracleParameter[] { // new OracleParameter(":goodsEnding",goodsEnding), // new OracleParameter(":productionDataID",productionDataID), // new OracleParameter(":accountid",sUserInfo.AccountID), // }; // int result = oracleTrConn.ExecuteNonQuery(sql, paras); // // 更新失败 // if (result <= Constant.INT_IS_ZERO) // { // return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); // } // // 成功返回null // return null; //} /// /// 添加责任工序 /// /// 连接对象 /// 责任工序 /// 缺陷数据 /// 用户基本信息 /// string private static string AddResponProcedure(IDBTransaction oracleTrConn, ResponProcedureEntity responProce, ProductionDefectEntity productionDefect, SUserInfo sUserInfo) { OracleParameter[] oracleParameters = null; string sql = null; int result = 0; // 查询新插入ID if (productionDefect.DefectProcedureID != null) { sql = "select SEQ_PM_ResponProcedure_ID.nextval from dual"; string idStr = oracleTrConn.GetSqlResultToStr(sql); if (!string.IsNullOrEmpty(idStr)) { responProce.ResponProcedureID = int.Parse(idStr); } else { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } #region SQL sql = "insert into tp_pm_responprocedure" + " (ResponProcedureID," + " scrapproductid," + " barcode," + " productiondataid," + " productionlineid," + " productionlinecode," + " productionlinename," + " procedureid," + " procedurecode," + " procedurename," + " userid," + " usercode," + " username," + " remarks," + " accountid," + " createuserid," + " updateuserid)" + " values" + " (" + " :ResponProcedureID," + " :scrapproductid," + " :barcode," + " :productiondataid," + " :productionlineid," + " :productionlinecode," + " :productionlinename," + " :procedureid," + " :procedurecode," + " :procedurename," + " :userid," + " :usercode," + " :username," + " :remarks," + " :accountid," + " :createuserid," + " :updateuserid)"; #endregion #region 参数 oracleParameters = new OracleParameter[] { new OracleParameter(":ResponProcedureID",responProce.ResponProcedureID), new OracleParameter(":scrapproductid",responProce.ScrapProductID), new OracleParameter(":barcode",responProce.BarCode), new OracleParameter(":productiondataid",responProce.ProductionDataID), new OracleParameter(":productionlineid",responProce.ProductionLineID), new OracleParameter(":productionlinecode",responProce.ProductionLineCode), new OracleParameter(":productionlinename",responProce.ProductionLineName), new OracleParameter(":procedureid",responProce.ProcedureID), new OracleParameter(":procedurecode",responProce.ProcedureCode), new OracleParameter(":procedurename",responProce.ProcedureName), new OracleParameter(":userid",responProce.UserID), new OracleParameter(":usercode",responProce.UserCode), new OracleParameter(":username",responProce.UserName), new OracleParameter(":remarks",responProce.Remarks), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), }; #endregion result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } //// 查询新插入ID //sql = "select SEQ_PM_ResponProcedure_ID.Currval from dual"; //string idStr = oracleTrConn.GetSqlResultToStr(sql); //if (!string.IsNullOrEmpty(idStr)) //{ // responProce.ResponProcedureID = int.Parse(idStr); //} //else //{ // return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); //} } #region 插入责任人 foreach (DefectResponsibleEntity defectResponsible in productionDefect.DefectResponsibles) { #region SQL sql = "insert into tp_pm_scrapresponsible" + " (barcode," + " scrapproductid," + " staffid," + " userid," + " usercode," + " ujobsid," + " sjobsid," + " staffstatus," + " accountid," + " createuserid," + " updateuserid," + " responprocedureid," + " respontype)" + " values" + " (:barcode," + " :scrapproductid," + " :staffid," + " :userid," + " :usercode," + " :ujobsid," + " :sjobsid," + " :staffstatus," + " :accountid," + " :createuserid," + " :updateuserid," + " :responprocedureid," + " :respontype)"; #endregion #region 参数 oracleParameters = new OracleParameter[] { new OracleParameter(":scrapproductid",responProce.ScrapProductID), new OracleParameter(":barcode",responProce.BarCode), new OracleParameter(":staffid",defectResponsible.StaffID), new OracleParameter(":userid",defectResponsible.UserID), new OracleParameter(":usercode",defectResponsible.UserCode), new OracleParameter(":ujobsid",defectResponsible.UJobsID), new OracleParameter(":sjobsid",defectResponsible.SJobsID), new OracleParameter(":staffstatus",defectResponsible.StaffStatus), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":responprocedureid",responProce.ResponProcedureID), new OracleParameter(":respontype",Constant.ScrapResponType.Procedure.GetHashCode()), }; #endregion result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } } #endregion return null; } /// /// 保存废弃产品 /// /// 连接对象 /// 报废产品 /// 用户基本信息 /// string private static string AddScrapProductRejectToReject(IDBTransaction oracleTrConn, ScrapProductEntity scrapProduct, SUserInfo sUserInfo) { #region sql string sql = "insert into tp_pm_scrapproduct" + " (scrapproductid,barcode," + " productionlineid," + " productionlinecode," + " productionlinename," + " goodsid," + " goodscode," + " goodsname," + " groutingdailyid," + " groutingdailydetailid," + " groutingdate," + " groutinglineid," + " groutinglinecode," + " groutinglinename," + " gmouldtypeid," + " groutinglinedetailid," + " groutingmouldcode," + " mouldcode," + " scrapdate," + " rreason," + " remarks," + " auditstatus," + " auditor," + " auditdate," + " accountdate," + " accountid," + " createuserid," + " updateuserid," + " respontype,GoodsLevelID,GoodsLevelTypeID," + " auditopinion," + " GroutingUserID," + " GroutingUserCode," + " GroutingNum," + " IsPublicBody," + " IsReFire," + " kilnid," + " kilncode," + " kilnname," + " kilncarid," + " kilncarcode," + " kilncarname," + " kilncarbatchno," + " kilncarposition," + " specialRepairflag," + " logoid,ProductionDataID, " + " ProcedureID, " + " ProcedureCode, " + " ProcedureName, " + " ScrapType " + ")" + " select :scrapproductid,trash.barcode," + " trash.productionlineid," + " trash.productionlinecode," + " trash.productionlinename," + " trash.goodsid," + " trash.goodscode," + " trash.goodsname," + " trash.groutingdailyid," + " trash.groutingdailydetailid," + " trash.groutingdate," + " trash.groutinglineid," + " trash.groutinglinecode," + " trash.groutinglinename," + " trash.gmouldtypeid," + " trash.groutinglinedetailid," + " trash.groutingmouldcode," + " trash.mouldcode," + " :scrapdate," + " :rreason," + " :remarks," + " :auditstatus," + " :auditor," // + " :auditdate," + " sysdate," + " :accountdate," + " trash.accountid," + " :createuserid," + " :updateuserid," + " :respontype,:GoodsLevelID,:GoodsLevelTypeID," + " :auditopinion," + " trash.GroutingUserID," + " trash.GroutingUserCode," + " trash.GroutingNum," + " trash.IsPublicBody," + " trash.IsReFire," + " trash.kilnid," + " trash.kilncode," + " trash.kilnname," + " trash.kilncarid," + " trash.kilncarcode," + " trash.kilncarname," + " trash.kilncarbatchno," + " trash.kilncarposition," + " trash.specialRepairflag," + " trash.logoid,:ProductionDataID," + " TP_PC_Procedure.ProcedureID, " + " TP_PC_Procedure.ProcedureCode, " + " TP_PC_Procedure.ProcedureName, " + " :ScrapType " + " from tp_pm_inproductiontrash trash" + " left join TP_PC_Procedure on trash.FlowProcedureID=TP_PC_Procedure.ProcedureID" + " where trash.barcode = :barcode"; #endregion #region 参数 OracleParameter[] oracleParameters = null; oracleParameters = new OracleParameter[] { new OracleParameter(":scrapproductid",OracleDbType.Int32,scrapProduct.ScrapProductID,ParameterDirection.Input), new OracleParameter(":scrapdate",OracleDbType.Date,scrapProduct.ScrapDate,ParameterDirection.Input), new OracleParameter(":rreason",OracleDbType.Varchar2,scrapProduct.Rreason,ParameterDirection.Input), new OracleParameter(":remarks",OracleDbType.Varchar2,scrapProduct.Remarks,ParameterDirection.Input), new OracleParameter(":auditstatus",OracleDbType.Int32,scrapProduct.AuditStatus,ParameterDirection.Input), new OracleParameter(":auditor",OracleDbType.Int32,scrapProduct.Auditor,ParameterDirection.Input), //new OracleParameter(":auditdate",OracleDbType.Date,scrapProduct.AuditlDate,ParameterDirection.Input), new OracleParameter(":accountdate",OracleDbType.Date,scrapProduct.AccountDate,ParameterDirection.Input), new OracleParameter(":createuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":updateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":respontype",OracleDbType.Varchar2,scrapProduct.ResponType,ParameterDirection.Input), new OracleParameter(":auditopinion",OracleDbType.Varchar2,scrapProduct.AuditOpinion,ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2,scrapProduct.BarCode,ParameterDirection.Input), new OracleParameter(":GoodsLevelID",OracleDbType.Int32,scrapProduct.GoodsLevelID,ParameterDirection.Input), new OracleParameter(":GoodsLevelTypeID",OracleDbType.Int32,scrapProduct.GoodsLevelTypeID,ParameterDirection.Input), new OracleParameter(":ScrapType",OracleDbType.Int32,scrapProduct.ScrapType,ParameterDirection.Input), new OracleParameter(":ProductionDataID",OracleDbType.Int32,scrapProduct.ProductionDataID,ParameterDirection.Input), }; #endregion int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); // result += oracleTrConn.ExecuteNonQuery(sql2, oracleParameters); //// 保存失败 //if (result != Constant.INT_IS_ONE) //{ // return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); //} return null; } /// /// 保存废弃产品 /// /// 连接对象 /// 报废产品 /// 用户基本信息 /// string private static string AddScrapProduct(IDBTransaction oracleTrConn, ScrapProductEntity scrapProduct, SUserInfo sUserInfo) { #region sql string sql = "insert into tp_pm_scrapproduct" + " (scrapproductid,barcode," + " productionlineid," + " productionlinecode," + " productionlinename," + " goodsid," + " goodscode," + " goodsname," + " groutingdailyid," + " groutingdailydetailid," + " groutingdate," + " groutinglineid," + " groutinglinecode," + " groutinglinename," + " gmouldtypeid," + " groutinglinedetailid," + " groutingmouldcode," + " mouldcode," + " scrapdate," + " rreason," + " remarks," + " auditstatus," + " auditor," + " auditdate," + " accountdate," + " accountid," + " createuserid," + " updateuserid," + " respontype,GoodsLevelID,GoodsLevelTypeID," + " auditopinion," + " GroutingUserID," + " GroutingUserCode," + " GroutingNum," + " IsPublicBody," + " IsReFire," + " kilnid," + " kilncode," + " kilnname," + " kilncarid," + " kilncarcode," + " kilncarname," + " kilncarbatchno," + " kilncarposition," + " specialRepairflag," + " logoid," + " ProductionDataID, " + " ProcedureID, " + " ProcedureCode, " + " ProcedureName, " + " ScrapType " + ")" + " select :scrapproductid,barcode," + " InProduction.productionlineid," + " InProduction.productionlinecode," + " InProduction.productionlinename," + " InProduction.goodsid," + " InProduction.goodscode," + " InProduction.goodsname," + " InProduction.groutingdailyid," + " InProduction.groutingdailydetailid," + " InProduction.groutingdate," + " InProduction.groutinglineid," + " InProduction.groutinglinecode," + " InProduction.groutinglinename," + " InProduction.gmouldtypeid," + " InProduction.groutinglinedetailid," + " InProduction.groutingmouldcode," + " InProduction.mouldcode," + " :scrapdate," + " :rreason," + " :remarks," + " :auditstatus," + " :auditor," // + " :auditdate," + " sysdate," + " :accountdate," + " InProduction.accountid," + " :createuserid," + " :updateuserid," + " :respontype,:GoodsLevelID,:GoodsLevelTypeID," + " :auditopinion," + " InProduction.GroutingUserID," + " InProduction.GroutingUserCode," + " InProduction.GroutingNum," + " InProduction.IsPublicBody," + " InProduction.IsReFire," + " InProduction.kilnid," + " InProduction.kilncode," + " InProduction.kilnname," + " InProduction.kilncarid," + " InProduction.kilncarcode," + " InProduction.kilncarname," + " InProduction.kilncarbatchno," + " InProduction.kilncarposition," + " InProduction.specialRepairflag," + " InProduction.logoid,"; if (scrapProduct.IsQualityStatistics == null) { sql += " InProduction.ProductionDataID,"; } else { sql += " :ProductionDataID,"; } sql += " TP_PC_Procedure.ProcedureID, " + " TP_PC_Procedure.ProcedureCode, " + " TP_PC_Procedure.ProcedureName, " + " :ScrapType" + " from TP_PM_InProduction InProduction" + " left join TP_PC_Procedure on InProduction.FlowProcedureID=TP_PC_Procedure.ProcedureID" + " where InProduction.barcode = :barcode"; #endregion #region 参数 OracleParameter[] oracleParameters = null; if (scrapProduct.IsQualityStatistics == null) { oracleParameters = new OracleParameter[] { new OracleParameter(":scrapproductid",OracleDbType.Int32,scrapProduct.ScrapProductID,ParameterDirection.Input), new OracleParameter(":scrapdate",OracleDbType.Date,scrapProduct.ScrapDate,ParameterDirection.Input), new OracleParameter(":rreason",OracleDbType.Varchar2,scrapProduct.Rreason,ParameterDirection.Input), new OracleParameter(":remarks",OracleDbType.Varchar2,scrapProduct.Remarks,ParameterDirection.Input), new OracleParameter(":auditstatus",OracleDbType.Int32,scrapProduct.AuditStatus,ParameterDirection.Input), new OracleParameter(":auditor",OracleDbType.Int32,scrapProduct.Auditor,ParameterDirection.Input), //new OracleParameter(":auditdate",OracleDbType.Date,scrapProduct.AuditlDate,ParameterDirection.Input), new OracleParameter(":accountdate",OracleDbType.Date,scrapProduct.AccountDate,ParameterDirection.Input), new OracleParameter(":createuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":updateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":respontype",OracleDbType.Varchar2,scrapProduct.ResponType,ParameterDirection.Input), new OracleParameter(":auditopinion",OracleDbType.Varchar2,scrapProduct.AuditOpinion,ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2,scrapProduct.BarCode,ParameterDirection.Input), new OracleParameter(":GoodsLevelID",OracleDbType.Int32,scrapProduct.GoodsLevelID,ParameterDirection.Input), new OracleParameter(":GoodsLevelTypeID",OracleDbType.Int32,scrapProduct.GoodsLevelTypeID,ParameterDirection.Input), new OracleParameter(":ScrapType",OracleDbType.Int32,scrapProduct.ScrapType,ParameterDirection.Input), }; } else { oracleParameters = new OracleParameter[] { new OracleParameter(":scrapproductid",OracleDbType.Int32,scrapProduct.ScrapProductID,ParameterDirection.Input), new OracleParameter(":scrapdate",OracleDbType.Date,scrapProduct.ScrapDate,ParameterDirection.Input), new OracleParameter(":rreason",OracleDbType.Varchar2,scrapProduct.Rreason,ParameterDirection.Input), new OracleParameter(":remarks",OracleDbType.Varchar2,scrapProduct.Remarks,ParameterDirection.Input), new OracleParameter(":auditstatus",OracleDbType.Int32,scrapProduct.AuditStatus,ParameterDirection.Input), new OracleParameter(":auditor",OracleDbType.Int32,scrapProduct.Auditor,ParameterDirection.Input), //new OracleParameter(":auditdate",OracleDbType.Date,scrapProduct.AuditlDate,ParameterDirection.Input), new OracleParameter(":accountdate",OracleDbType.Date,scrapProduct.AccountDate,ParameterDirection.Input), new OracleParameter(":createuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":updateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":respontype",OracleDbType.Varchar2,scrapProduct.ResponType,ParameterDirection.Input), new OracleParameter(":auditopinion",OracleDbType.Varchar2,scrapProduct.AuditOpinion,ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2,scrapProduct.BarCode,ParameterDirection.Input), new OracleParameter(":GoodsLevelID",OracleDbType.Int32,scrapProduct.GoodsLevelID,ParameterDirection.Input), new OracleParameter(":GoodsLevelTypeID",OracleDbType.Int32,scrapProduct.GoodsLevelTypeID,ParameterDirection.Input), new OracleParameter(":ScrapType",OracleDbType.Int32,scrapProduct.ScrapType,ParameterDirection.Input), new OracleParameter(":ProductionDataID",OracleDbType.Int32,scrapProduct.ProductionDataID,ParameterDirection.Input), }; } #endregion int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); if (result == 0) { sql = "insert into tp_pm_scrapproduct" + " (scrapproductid,barcode," + " productionlineid," + " productionlinecode," + " productionlinename," + " goodsid," + " goodscode," + " goodsname," + " groutingdailyid," + " groutingdailydetailid," + " groutingdate," + " groutinglineid," + " groutinglinecode," + " groutinglinename," + " gmouldtypeid," + " groutinglinedetailid," + " groutingmouldcode," + " mouldcode," + " scrapdate," + " rreason," + " remarks," + " auditstatus," + " auditor," + " auditdate," + " accountdate," + " accountid," + " createuserid," + " updateuserid," + " respontype,GoodsLevelID,GoodsLevelTypeID," + " auditopinion," + " GroutingUserID," + " GroutingUserCode," + " GroutingNum," + " IsPublicBody," + " IsReFire," + " kilnid," + " kilncode," + " kilnname," + " kilncarid," + " kilncarcode," + " kilncarname," + " kilncarbatchno," + " kilncarposition," + " specialRepairflag," + " logoid," + " ProductionDataID," + " ProcedureID, " + " ProcedureCode, " + " ProcedureName, " + " ScrapType " + ")" + " select :scrapproductid,trash.barcode," + " trash.productionlineid," + " trash.productionlinecode," + " trash.productionlinename," + " trash.goodsid," + " trash.goodscode," + " trash.goodsname," + " trash.groutingdailyid," + " trash.groutingdailydetailid," + " trash.groutingdate," + " trash.groutinglineid," + " trash.groutinglinecode," + " trash.groutinglinename," + " trash.gmouldtypeid," + " trash.groutinglinedetailid," + " trash.groutingmouldcode," + " trash.mouldcode," + " :scrapdate," + " :rreason," + " :remarks," + " :auditstatus," + " :auditor," //+ " :auditdate," + " sysdate," + " :accountdate," + " trash.accountid," + " :createuserid," + " :updateuserid," + " :respontype,:GoodsLevelID,:GoodsLevelTypeID," + " :auditopinion," + " trash.GroutingUserID," + " trash.GroutingUserCode," + " trash.GroutingNum," + " trash.IsPublicBody," + " trash.IsReFire," + " trash.kilnid," + " trash.kilncode," + " trash.kilnname," + " trash.kilncarid," + " trash.kilncarcode," + " trash.kilncarname," + " trash.kilncarbatchno," + " trash.kilncarposition," + " trash.specialRepairflag," + " trash.logoid,"; if (scrapProduct.IsQualityStatistics == null) { sql += " trash.ProductionDataID,"; } else { sql += " :ProductionDataID,"; } sql += //" trash.ProductionDataID," + " TP_PC_Procedure.ProcedureID, " + " TP_PC_Procedure.ProcedureCode, " + " TP_PC_Procedure.ProcedureName, " + " :ScrapType " + " from TP_PM_InProductionTrash trash" + " left join TP_PC_Procedure on trash.FlowProcedureID=TP_PC_Procedure.ProcedureID" + " where trash.barcode = :barcode"; result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); } // result += oracleTrConn.ExecuteNonQuery(sql2, oracleParameters); //// 保存失败 //if (result != Constant.INT_IS_ONE) //{ // return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); //} return null; } /// /// 保存缺陷 /// /// 连接对象 /// 缺陷数据 /// 用户基本信息 /// string private static string AddDefect(IDBTransaction oracleTrConn, ProductionDefectEntity productionDefect, SUserInfo sUserInfo) { // 查询新插入的生产数据ID string sql = "select SEQ_PM_Defect_DefectID.nextval from dual"; string idStr = oracleTrConn.GetSqlResultToStr(sql); int productionDefectID = 0; if (!string.IsNullOrEmpty(idStr)) { productionDefectID = int.Parse(idStr); } else { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } #region SQL sql = "insert into tp_pm_defect" + " ( ProductionDefectID," + " productiondataid," + " barcode," + " productionlineid," + " productionlinecode," + " productionlinename," + " procedureid," + " procedurecode," + " procedurename," + " userid," + " usercode," + " username," + " goodsid," + " goodscode," + " goodsname," + " defectid," + " defectcode," + " defectname," + " defectpositionid," + " defectpositioncode," + " defectpositionname," + " scrapResponFlag," + " defectproductiondataid," + " defectprocedureid," + " defectprocedurecode," + " defectprocedurename," + " defectuserid," + " defectusercode," + " defectusername," + " defectjobs," + " remarks," + " accountid," + " createuserid," + " defectfine," + " misseduserid," + " missedusercode," + " missedusername," + " updateuserid,SpecialDefect,DefectDeductionNum,CheckTime)" + " values" + " (" + " :ProductionDefectID," + " :productiondataid," + " :barcode," + " :productionlineid," + " :productionlinecode," + " :productionlinename," + " :procedureid," + " :procedurecode," + " :procedurename," + " :userid," + " :usercode," + " :username," + " :goodsid," + " :goodscode," + " :goodsname," + " :defectid," + " :defectcode," + " :defectname," + " :defectpositionid," + " :defectpositioncode," + " :defectpositionname," + " :scrapResponFlag," + " :defectproductiondataid," + " :defectprocedureid," + " :defectprocedurecode," + " :defectprocedurename," + " :defectuserid," + " :defectusercode," + " :defectusername," + " :defectjobs," + " :remarks," + " :accountid," + " :createuserid," + " :defectfine," + " :misseduserid," + " :missedusercode," + " :missedusername," + " :updateuserid,:SpecialDefect,:DefectDeductionNum,:CheckTime)"; #endregion #region 参数 OracleParameter[] oracleParameters = null; if (productionDefect.IsPDA == null) { oracleParameters = new OracleParameter[] { new OracleParameter(":ProductionDefectID",productionDefectID), new OracleParameter(":productiondataid",productionDefect.ProductionDataID), new OracleParameter(":barcode",productionDefect.BarCode), new OracleParameter(":productionlineid",productionDefect.ProductionLineID), new OracleParameter(":productionlinecode",productionDefect.ProductionLineCode), new OracleParameter(":productionlinename",productionDefect.ProductionLineName), new OracleParameter(":procedureid",productionDefect.ProcedureID), new OracleParameter(":procedurecode",productionDefect.ProcedureCode), new OracleParameter(":procedurename",productionDefect.ProcedureName), new OracleParameter(":userid",productionDefect.UserID), new OracleParameter(":usercode",productionDefect.UserCode), new OracleParameter(":username",productionDefect.UserName), new OracleParameter(":goodsid",productionDefect.GoodsID), new OracleParameter(":goodscode",productionDefect.GoodsCode), new OracleParameter(":goodsname",productionDefect.GoodsName), new OracleParameter(":defectid",productionDefect.DefectID), new OracleParameter(":defectcode",productionDefect.DefectCode), new OracleParameter(":defectname",productionDefect.DefectName), new OracleParameter(":defectpositionid",productionDefect.DefectPositionID), new OracleParameter(":defectpositioncode",productionDefect.DefectPositionCode), new OracleParameter(":defectpositionname",productionDefect.DefectPositionName), new OracleParameter(":scrapResponFlag",productionDefect.ScrapResponFlag), new OracleParameter(":defectproductiondataid",productionDefect.DefectProductionDataID), new OracleParameter(":defectprocedureid",productionDefect.DefectProcedureID), new OracleParameter(":defectprocedurecode",productionDefect.DefectProcedureCode), new OracleParameter(":defectprocedurename",productionDefect.DefectProcedureName), new OracleParameter(":defectuserid",productionDefect.DefectUserID), new OracleParameter(":defectusercode",productionDefect.DefectUserCode), new OracleParameter(":defectusername",productionDefect.DefectUserName), new OracleParameter(":defectjobs",productionDefect.DefectJobs), new OracleParameter(":remarks",productionDefect.Remarks), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":defectfine",productionDefect.DefectFine), new OracleParameter(":misseduserid",productionDefect.MissedUserID), new OracleParameter(":missedusercode",productionDefect.MissedUserCode), new OracleParameter(":missedusername",productionDefect.MissedUserName), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":SpecialDefect",productionDefect.SpecialDefect==null?"0":productionDefect.SpecialDefect), new OracleParameter(":DefectDeductionNum",productionDefect.DefectDeductionNum==null?0:productionDefect.DefectDeductionNum), new OracleParameter(":CheckTime",productionDefect.CheckTime.ToString()==string.Empty?null:productionDefect.CheckTime), }; } else { DateTime? pdaCheckTime = null; if (productionDefect.PDACheckTime != null) { if (productionDefect.PDACheckTime.ToString() != string.Empty) { pdaCheckTime = Convert.ToDateTime(productionDefect.PDACheckTime); } } oracleParameters = new OracleParameter[] { new OracleParameter(":ProductionDefectID",productionDefectID), new OracleParameter(":productiondataid",productionDefect.ProductionDataID), new OracleParameter(":barcode",productionDefect.BarCode), new OracleParameter(":productionlineid",productionDefect.ProductionLineID), new OracleParameter(":productionlinecode",productionDefect.ProductionLineCode), new OracleParameter(":productionlinename",productionDefect.ProductionLineName), new OracleParameter(":procedureid",productionDefect.ProcedureID), new OracleParameter(":procedurecode",productionDefect.ProcedureCode), new OracleParameter(":procedurename",productionDefect.ProcedureName), new OracleParameter(":userid",productionDefect.UserID), new OracleParameter(":usercode",productionDefect.UserCode), new OracleParameter(":username",productionDefect.UserName), new OracleParameter(":goodsid",productionDefect.GoodsID), new OracleParameter(":goodscode",productionDefect.GoodsCode), new OracleParameter(":goodsname",productionDefect.GoodsName), new OracleParameter(":defectid",productionDefect.DefectID), new OracleParameter(":defectcode",productionDefect.DefectCode), new OracleParameter(":defectname",productionDefect.DefectName), new OracleParameter(":defectpositionid",productionDefect.DefectPositionID), new OracleParameter(":defectpositioncode",productionDefect.DefectPositionCode), new OracleParameter(":defectpositionname",productionDefect.DefectPositionName), new OracleParameter(":scrapResponFlag",productionDefect.ScrapResponFlag), new OracleParameter(":defectproductiondataid",productionDefect.DefectProductionDataID), new OracleParameter(":defectprocedureid",productionDefect.DefectProcedureID), new OracleParameter(":defectprocedurecode",productionDefect.DefectProcedureCode), new OracleParameter(":defectprocedurename",productionDefect.DefectProcedureName), new OracleParameter(":defectuserid",productionDefect.DefectUserID), new OracleParameter(":defectusercode",productionDefect.DefectUserCode), new OracleParameter(":defectusername",productionDefect.DefectUserName), new OracleParameter(":defectjobs",productionDefect.DefectJobs), new OracleParameter(":remarks",productionDefect.Remarks), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":defectfine",productionDefect.DefectFine), new OracleParameter(":misseduserid",productionDefect.MissedUserID), new OracleParameter(":missedusercode",productionDefect.MissedUserCode), new OracleParameter(":missedusername",productionDefect.MissedUserName), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":SpecialDefect",productionDefect.SpecialDefect==null?"0":productionDefect.SpecialDefect), new OracleParameter(":DefectDeductionNum",productionDefect.DefectDeductionNum==null?0:productionDefect.DefectDeductionNum), new OracleParameter(":CheckTime",pdaCheckTime), }; } #endregion int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } //// 查询新插入的生产数据ID //sql = "select SEQ_PM_Defect_DefectID.Currval from dual"; //string idStr = oracleTrConn.GetSqlResultToStr(sql); //int productionDefectID = 0; //if (!string.IsNullOrEmpty(idStr)) //{ // productionDefectID = int.Parse(idStr); //} //else //{ // return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); //} #region 插入生产缺陷责任者 if (productionDefect.DefectResponsibles != null) { foreach (DefectResponsibleEntity DefectResponsible in productionDefect.DefectResponsibles) { #region SQL sql = "insert into tp_pm_defectresponsible" + " (productiondefectid," + " staffid," + " userid," + " usercode," + " Ujobsid," + " SJobsID," + " staffstatus," + " accountid," + " createuserid," + " updateuserid)" + " values" + " (:productiondefectid," + " :staffid," + " :userid," + " :usercode," + " :ujobsid," + " :sjobsid," + " :staffstatus," + " :accountid," + " :createuserid," + " :updateuserid)"; #endregion #region 参数 oracleParameters = new OracleParameter[] { new OracleParameter(":productiondefectid",productionDefectID), new OracleParameter(":staffid",DefectResponsible.StaffID), new OracleParameter(":userid",DefectResponsible.UserID), new OracleParameter(":usercode",DefectResponsible.UserCode), new OracleParameter(":ujobsid",DefectResponsible.UJobsID), new OracleParameter(":sjobsid",DefectResponsible.SJobsID), new OracleParameter(":staffstatus",DefectResponsible.StaffStatus), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), }; #endregion result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } } } #endregion #region 插入生产漏检缺陷责任者 if (productionDefect.DefectMissedResponsibles != null) { foreach (DefectMissedResponsibleEntity DefectMissedResponsible in productionDefect.DefectMissedResponsibles) { #region SQL sql = "insert into TP_PM_DefectMissedResponsible" + " (productiondefectid," + " staffid," + " userid," + " usercode," + " Ujobsid," + " SJobsID," + " staffstatus," + " accountid," + " createuserid," + " updateuserid)" + " values" + " (:productiondefectid," + " :staffid," + " :userid," + " :usercode," + " :ujobsid," + " :sjobsid," + " :staffstatus," + " :accountid," + " :createuserid," + " :updateuserid)"; #endregion #region 参数 oracleParameters = new OracleParameter[] { new OracleParameter(":productiondefectid",productionDefectID), new OracleParameter(":staffid",DefectMissedResponsible.StaffID), new OracleParameter(":userid",DefectMissedResponsible.UserID), new OracleParameter(":usercode",DefectMissedResponsible.UserCode), new OracleParameter(":ujobsid",DefectMissedResponsible.UJobsID), new OracleParameter(":sjobsid",DefectMissedResponsible.SJobsID), new OracleParameter(":staffstatus",DefectMissedResponsible.StaffStatus), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), }; #endregion result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } } } #endregion #region 添加图片 if (productionDefect.DefectImages != null) { DateTime upTime = DateTime.Now; foreach (DefectImageEntity defectImage in productionDefect.DefectImages) { // 图片路径为空。上传图片返回路径 if (string.IsNullOrEmpty(defectImage.ImagePath)) { defectImage.ImagePath = CommonModuleLogic.CommonModuleLogic .UpLoadImg(Constant.SYSTEM_MODULE_PM, upTime, defectImage.Image); defectImage.ThumbnailPath = CommonModuleLogic.CommonModuleLogic .ConvertThumbnail(Constant.SYSTEM_MODULE_PM, upTime, defectImage.Image); } else { // 安卓端上传的图片 defectImage.ImagePath = CommonModuleLogic.CommonModuleLogic .MoveImg(Constant.SYSTEM_MODULE_PM, upTime, defectImage.ImagePath); defectImage.ThumbnailPath = CommonModuleLogic.CommonModuleLogic .ConvertThumbnail(Constant.SYSTEM_MODULE_PM, upTime, defectImage.ImagePath); } #region 保存图片 sql = "insert into tp_pm_defectimage" + " (" + " productiondefectid," + " barcode," + " thumbnailpath," + " imagepath," + " accountid," + " createuserid," + " updateuserid)" + " values" + " (" + " :productiondefectid," + " :barcode," + " :thumbnailpath," + " :imagepath," + " :accountid," + " :createuserid," + " :updateuserid)"; oracleParameters = new OracleParameter[] { new OracleParameter(":productiondefectid",productionDefectID), new OracleParameter(":barcode",productionDefect.BarCode), new OracleParameter(":thumbnailpath",defectImage.ThumbnailPath), new OracleParameter(":imagepath",defectImage.ImagePath), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), }; result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } #endregion } } #endregion // 保存成功返回null return null; } #endregion #region 进度考核奖惩 /// /// 根据传入的实体保存 进度考核奖惩记录 /// /// 进度考核奖惩实体 /// 用户基本信息 /// 新增还是编辑枚举 /// PMResultEntity操作结果状态信息 public static PMResultEntity SaveStaffProgressRAPInfo(PMProgressRAPEntity pProgressRAPEntity, SUserInfo sUserInfo, WCFConstant.FormMode pStatus) { PMResultEntity resultEnity = new PMResultEntity(); IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { if (pProgressRAPEntity == null) { resultEnity.OperateStatus = 0; return resultEnity; } oracleTrConn.Connect(); if (pStatus == WCFConstant.FormMode.Add) { string strSeq = oracleTrConn.GetSqlResultToStr("Select SEQ_PM_ProgressRAP_RAPID.nextval from dual"); #region 新建时插入数据 string strSql1 = "Insert Into TP_PM_ProgressRAP (RAPID," + "STAFFID" + ",RAPTYPE" + ",REASON" + ",RAPDATE" + ",RAPAMOUNT" + ",REMARKS" + ",AUDITSTATUS" + ",ACCOUNTID" + ",CREATEUSERID" + ",UPDATEUSERID)" + " Values (" + ":RAPID" + ",:pSTAFFID" + ",:pRAPTYPE" + ",:pREASON" + ",:pRAPDATE" + ",:pRAPAMOUNT" + ",:pREMARKS" + ",:pAUDITSTATUS" + ",:pACCOUNTID" + ",:pCREATEUSERID" + ",:pUPDATEUSERID" + ")"; OracleParameter[] parmetersSql1 = new OracleParameter[] { new OracleParameter(":RAPID", OracleDbType.Int32, Convert.ToInt32(strSeq) , ParameterDirection.Input), new OracleParameter(":pSTAFFID", OracleDbType.Int32, pProgressRAPEntity.StaffID , ParameterDirection.Input), new OracleParameter(":pRAPTYPE", OracleDbType.Double, pProgressRAPEntity.RAPType , ParameterDirection.Input), new OracleParameter(":pREASON", OracleDbType.Varchar2, pProgressRAPEntity.Reason , ParameterDirection.Input), new OracleParameter(":pRAPDATE", OracleDbType.Date, pProgressRAPEntity.RAPDate , ParameterDirection.Input), new OracleParameter(":pRAPAMOUNT", OracleDbType.Double, pProgressRAPEntity.RAPAmount , ParameterDirection.Input), new OracleParameter(":pREMARKS", OracleDbType.Varchar2, pProgressRAPEntity.Remarks , ParameterDirection.Input), new OracleParameter(":pAUDITSTATUS", OracleDbType.Int32, 0 , ParameterDirection.Input), new OracleParameter(":pACCOUNTID", OracleDbType.Int32, sUserInfo.AccountID , ParameterDirection.Input), new OracleParameter(":pCREATEUSERID", OracleDbType.Int32, sUserInfo.UserID , ParameterDirection.Input), new OracleParameter(":pUPDATEUSERID", OracleDbType.Int32, sUserInfo.UserID , ParameterDirection.Input), }; #endregion resultEnity.OperateStatus = oracleTrConn.ExecuteNonQuery(strSql1, parmetersSql1); //string strSeq = oracleTrConn.GetSqlResultToStr("Select SEQ_PM_ProgressRAP_RAPID.Currval from dual"); resultEnity.OperateKey = Convert.ToInt32(strSeq); } else { #region 判断数据是否可以编辑 string strSlq2 = "Select max(AuditStatus) From TP_PM_ProgressRAP Where RAPID = :pRAPID And OPTimeStamp = :pOPTimeStamp"; OracleParameter[] parmetersSql2 = new OracleParameter[] { new OracleParameter(":pRAPID", OracleDbType.Int32, pProgressRAPEntity.RAPID , ParameterDirection.Input), new OracleParameter(":pOPTimeStamp", OracleDbType.TimeStamp, pProgressRAPEntity.OPTimeStamp , ParameterDirection.Input), }; string strAuditStatus = oracleTrConn.GetSqlResultToStr(strSlq2, parmetersSql2); if (string.IsNullOrEmpty(strAuditStatus)) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); resultEnity.OperateStatus = -2; return resultEnity; } if (!"0".Equals(strAuditStatus)) { //不是待审批状态 oracleTrConn.Rollback(); oracleTrConn.Disconnect(); resultEnity.OperateStatus = -1; return resultEnity; } #endregion #region 编辑时更新数据 string strSql3 = "Update TP_PM_ProgressRAP Set " + "RAPTYPE = :pRAPTYPE" + ",REASON = :pREASON" + ",RAPDATE = :pRAPDATE" + ",RAPAMOUNT = :pRAPAMOUNT" + ",REMARKS = :pREMARKS" + ",UPDATEUSERID = :pUPDATEUSERID" + " Where RAPID = :pRAPID And STAFFID = :pSTAFFID And AccountID = :pAccountID"; OracleParameter[] parmetersSql3 = new OracleParameter[] { new OracleParameter(":pRAPTYPE", OracleDbType.Double, pProgressRAPEntity.RAPType , ParameterDirection.Input), new OracleParameter(":pREASON", OracleDbType.Varchar2, pProgressRAPEntity.Reason , ParameterDirection.Input), new OracleParameter(":pRAPDATE", OracleDbType.Date, pProgressRAPEntity.RAPDate , ParameterDirection.Input), new OracleParameter(":pRAPAMOUNT", OracleDbType.Double, pProgressRAPEntity.RAPAmount , ParameterDirection.Input), new OracleParameter(":pREMARKS", OracleDbType.Varchar2, pProgressRAPEntity.Remarks , ParameterDirection.Input), new OracleParameter(":pUPDATEUSERID", OracleDbType.Int32, sUserInfo.UserID , ParameterDirection.Input), new OracleParameter(":pRAPID", OracleDbType.Int32, pProgressRAPEntity.RAPID , ParameterDirection.Input), new OracleParameter(":pSTAFFID", OracleDbType.Int32, pProgressRAPEntity.StaffID , ParameterDirection.Input), new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID , ParameterDirection.Input), }; #endregion resultEnity.OperateStatus = oracleTrConn.ExecuteNonQuery(strSql3, parmetersSql3); resultEnity.OperateKey = pProgressRAPEntity.RAPID; } oracleTrConn.Commit(); oracleTrConn.Disconnect(); return resultEnity; } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } } /// /// 进度考核奖惩审批 /// /// 进度考核奖惩实体 /// 审批状态 True 通过 False 不通过 /// 用户基本信息 /// PMResultEntity操作结果状态信息 public static PMResultEntity SaveStaffProgressRAPApprovalInfo(PMProgressRAPEntity pProgressRAPEntity, bool pState, SUserInfo sUserInfo) { PMResultEntity resultEnity = new PMResultEntity(); IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { if (pProgressRAPEntity == null) { resultEnity.OperateStatus = 0; return resultEnity; } oracleTrConn.Connect(); #region 判断数据是否可以编辑 string strSlq1 = "Select max(AuditStatus) From TP_PM_ProgressRAP Where RAPID = :pRAPID And OPTimeStamp = :pOPTimeStamp"; OracleParameter[] parmetersSql1 = new OracleParameter[] { new OracleParameter(":pRAPID", OracleDbType.Int32, pProgressRAPEntity.RAPID , ParameterDirection.Input), new OracleParameter(":pOPTimeStamp", OracleDbType.TimeStamp, pProgressRAPEntity.OPTimeStamp , ParameterDirection.Input), }; string strAuditStatus = oracleTrConn.GetSqlResultToStr(strSlq1, parmetersSql1); if (string.IsNullOrEmpty(strAuditStatus)) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); resultEnity.OperateStatus = -2; return resultEnity; } if (!"0".Equals(strAuditStatus)) { //不是待审批状态 oracleTrConn.Rollback(); oracleTrConn.Disconnect(); resultEnity.OperateStatus = -1; return resultEnity; } #endregion #region 更新审批数据 int intAuditStatus = 2; //2:审核未通过 if (pState) { intAuditStatus = 1; //1:审核通过; } string strSql2 = "Update TP_PM_ProgressRAP Set " + "AUDITSTATUS = :pAUDITSTATUS" + ",AUDITOR = :pAUDITOR" + ",AuditlDate = sysdate" + ",ACCOUNTDATE = FUN_CMN_GetAccountDate(:pAccountID1)" + ",UPDATEUSERID = :pUPDATEUSERID" + " Where RAPID = :pRAPID And AccountID = :pAccountID"; OracleParameter[] parmetersSql2 = new OracleParameter[] { new OracleParameter(":pAUDITSTATUS", OracleDbType.Int32,intAuditStatus, ParameterDirection.Input), new OracleParameter(":pAUDITOR", OracleDbType.Int32, sUserInfo.UserID , ParameterDirection.Input), new OracleParameter(":pAccountID1", OracleDbType.Int32, sUserInfo.AccountID , ParameterDirection.Input), new OracleParameter(":pUPDATEUSERID", OracleDbType.Int32, sUserInfo.UserID , ParameterDirection.Input), new OracleParameter(":pRAPID", OracleDbType.Int32, pProgressRAPEntity.RAPID , ParameterDirection.Input), new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID , ParameterDirection.Input), }; #endregion resultEnity.OperateStatus = oracleTrConn.ExecuteNonQuery(strSql2, parmetersSql2); resultEnity.OperateKey = pProgressRAPEntity.RAPID; oracleTrConn.Commit(); oracleTrConn.Disconnect(); return resultEnity; } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } } /// /// 设置进度考核奖惩停用 /// /// 进度考核奖惩编号 /// 用户基本信息 /// PMResultEntity操作结果状态信息 public static PMResultEntity SetStaffProgressRAPValueFlag(int pRAPID, SUserInfo sUserInfo) { PMResultEntity resultEnity = new PMResultEntity(); IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { oracleTrConn.Connect(); string sql = "Select max(SettlementFlag) From TP_PM_ProgressRAP Where RAPID =" + pRAPID + " And AuditStatus = 0 And ValueFlag = 1"; string strSettlementFlag = oracleTrConn.GetSqlResultToStr(sql); if (!string.IsNullOrEmpty(strSettlementFlag)) { if ("1".Equals(strSettlementFlag)) //工资结算标识 1:已经结算 0:未结算 { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); resultEnity.OperateStatus = -3; return resultEnity; } string sqlString = "Update TP_PM_ProgressRAP Set ValueFlag = 0,UpdateUserID = :pUpdateUserID" + " Where RAPID = :pRAPID And AccountID = :pAccountID"; OracleParameter[] parmetersSql = new OracleParameter[] { new OracleParameter(":pUpdateUserID", OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input), new OracleParameter(":pRAPID", OracleDbType.Int32, pRAPID , ParameterDirection.Input), new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID , ParameterDirection.Input), }; resultEnity.OperateStatus = oracleTrConn.ExecuteNonQuery(sqlString, parmetersSql); oracleTrConn.Commit(); oracleTrConn.Disconnect(); return resultEnity; } else { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); resultEnity.OperateStatus = -2; return resultEnity; } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } } #endregion #endregion #region 私有方法 /// /// 将窑车号下的条码转换成Table /// /// 数据连接 /// 手机传入的Table /// 用户基本信息 /// DataTable private static DataTable CarNoInfoConvertToTable(IDBTransaction oracleTrConn, DataTable productionTable, SUserInfo sUserInfo) { if (productionTable != null && productionTable.Rows.Count > Constant.INT_IS_ZERO) { DataRow row = productionTable.Rows[Constant.INT_IS_ZERO]; string sql = "select carGoods.Barcode," + " carGoods.KilnCarID," + " car.KilncarCode," + " car.KilncarName," + " kiln.kilnid," + " kiln.kilnCode," + " kiln.kilnName," + " carGoods.Kilncarposition," + " carGoods.KilnCarBatchNo," + " carGoods.GoodsID," + " goods.GoodsCode," + " goods.GoodsName," + " :userID as UserID," + " :userCode as UserCode," + " :userName as UserName," + " :Remarks as Remarks" + " from TP_PM_KilnCarGoods carGoods" + " inner join TP_MST_KilnCar car on car.KilnCarID = carGoods.KilnCarID" + " inner join TP_MST_Kiln kiln on kiln.KilnID = car.KilnID" + " inner join TP_MST_Goods goods on goods.goodsid = carGoods.GoodsID" + " where car.kilncarcode = :kilncarcode and carGoods.AccountID = :accountID"; OracleParameter[] oracleParameters = new OracleParameter[] { new OracleParameter(":userID",row["UserID"].ToString()), new OracleParameter(":userCode",row["UserCode"].ToString()), new OracleParameter(":userName",row["UserName"].ToString()), new OracleParameter(":kilncarcode",row["KilnCarCode"].ToString()), new OracleParameter(":accountID",sUserInfo.AccountID), new OracleParameter(":Remarks",row["Remarks"].ToString()), }; DataSet ds = oracleTrConn.GetSqlResultToDs(sql, oracleParameters); if (ds != null && ds.Tables.Count > Constant.INT_IS_ZERO && ds.Tables[0].Rows.Count > Constant.INT_IS_ZERO) { return ds.Tables[0]; } return productionTable; } return productionTable; } #endregion #region PDA端保存条码 /// /// 添加成品编辑 /// /// 数据连接 /// 工序对象 /// 生产数据集 /// 用户基本信息 /// string private static string AddFinishCheckPDA(IDBTransaction oracleTrConn, ProcedureEntity procedure, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo) { string errMsg = ""; // 获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); // 本批采集的批次号 string centralizedBatchNo = System.Guid.NewGuid().ToString(); string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo; foreach (ProductionDataEntity productionData in productionDataEntitys) { bool RejectToReject = false; if (string.IsNullOrEmpty(productionData.Barcode)) { throw new Exception("传入的条码号为空"); } int goodsID = Constant.INT_IS_ZERO; string goodsCode = string.Empty; string goodsName = string.Empty; // 注浆者工号 string groutingUserCode = string.Empty; // 次品标识 bool substandardFlag = false; #region 校验条码有效性 errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, productionData.Barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { // 编辑重烧时,会提示不可到达;编辑次品时,会提示已经报废 //if (productionData.ProductionDataID == 0) if (!errMsg.Contains("次品")) return errMsg; } #endregion #region 修改条码 if (productionData.ProductionDataID > 0) //表示编辑条码 { #region 验证改判有效期 // 前台已有相关验证,但还是产生了超期改判,后台保存前增加验证。 string sqlString = "select pdin.createtime from tp_pm_productiondatain pdin where pdin.productiondataid = " + productionData.ProductionDataID; DateTime createtime = Convert.ToDateTime(oracleTrConn.GetSqlResultToObj(sqlString)).Date; // 参数验证用服务端当前设置 sqlString = "SELECT sst.settingvalue\n" + " FROM tp_mst_systemsetting sst\n" + " WHERE sst.accountid = " + sUserInfo.AccountID + "\n" + " AND sst.settingcode = 'S_PM_009'"; string strValue = oracleTrConn.GetSqlResultToStr(sqlString); int days = 0; int pDays = 0; if (int.TryParse(strValue, out pDays)) { days = pDays; } if (days != 0 && createtime <= DateTime.Now.Date.AddDays(-days)) { return string.Format(Messages.MSG_S_PM_009, createtime.ToString("yyyy-MM-dd"), days.ToString(), createtime.AddDays(days - 1).ToString("yyyy-MM-dd")); } #endregion // string sqlOPTimeStamp = ""; OracleParameter[] parmetersSql = null; #region 验证在产时间戳 if (productionData.OPTimeStampPDA == null) // 表示PC端,因为只有安卓端才给此数据字段给值 { sqlOPTimeStamp = @"select 1 from TP_PM_InProduction where TP_PM_InProduction.BarCode=:BarCode and TP_PM_InProduction.OPTimeStamp = :OPTimeStamp union select 1 from Tp_Pm_Inproductiontrash where Tp_Pm_Inproductiontrash.BarCode=:BarCode and Tp_Pm_Inproductiontrash.OPTimeStamp = :OPTimeStamp "; parmetersSql = new OracleParameter[] { new OracleParameter(":OPTimeStamp", OracleDbType.TimeStamp, productionData.OPTimeStamp, ParameterDirection.Input), new OracleParameter(":BarCode", OracleDbType.NVarchar2, productionData.Barcode, ParameterDirection.Input), }; } else { sqlOPTimeStamp = @"select 1 from TP_PM_InProduction where TP_PM_InProduction.BarCode=:BarCode and TP_PM_InProduction.OPTimeStamp =TO_TIMESTAMP(to_char(:OPTimeStamp),'DD-MM-YYHH12.MI.SS.FFAM') union select 1 from Tp_Pm_Inproductiontrash where Tp_Pm_Inproductiontrash.BarCode=:BarCode and Tp_Pm_Inproductiontrash.OPTimeStamp =TO_TIMESTAMP(to_char(:OPTimeStamp),'DD-MM-YYHH12.MI.SS.FFAM')"; parmetersSql = new OracleParameter[] { new OracleParameter(":OPTimeStamp", OracleDbType.NVarchar2, productionData.OPTimeStampPDA, ParameterDirection.Input), new OracleParameter(":BarCode", OracleDbType.NVarchar2, productionData.Barcode, ParameterDirection.Input), }; } DataSet returnDataset = oracleTrConn.GetSqlResultToDs(sqlOPTimeStamp, parmetersSql); if (returnDataset != null && returnDataset.Tables[0].Rows.Count == 0) { return "数据已经被修改,请重新进行编辑"; } #endregion //如果原来是次品 if (productionData.OrgGoodsLevelTypeID == Constant.GoodsLevelType.Reject.GetHashCode()) { //改为次品 if (productionData.GoodsLevelTypeID == Constant.GoodsLevelType.Reject.GetHashCode()) { // 删除生产数据及相关表与报损表 errMsg = DeleteSubstandardToSubstandardByID(oracleTrConn, productionData.ProductionDataID, productionData.Barcode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } RejectToReject = true; } //改为不是次品 else if (productionData.GoodsLevelTypeID != Constant.GoodsLevelType.Reject.GetHashCode()) { // 删除生产数据及相关表与报损表 errMsg = DeleteSubstandardToOtherByID(oracleTrConn, productionData.ProductionDataID, productionData.Barcode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } } } else { // 原来产品分级不是次品 errMsg = DeleteNormalToOtherByID(oracleTrConn, productionData.ProductionDataID, productionData.Barcode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } } } else // wangx 2016-12-13 防止同时两个人新建数据,加判断条件 { string sqlCurrrentProcedure = @"select Flowprocedureid from tp_pm_inproduction where BarCode=:BarCode"; OracleParameter[] parmetersSql = null; parmetersSql = new OracleParameter[] { new OracleParameter(":BarCode", OracleDbType.NVarchar2, productionData.Barcode, ParameterDirection.Input), }; DataSet returnDataset = oracleTrConn.GetSqlResultToDs(sqlCurrrentProcedure, parmetersSql); // 判定次品时,在产表中已经没有条码数据 modify by chenxy 2017-07-03 begin //if (returnDataset != null // && returnDataset.Tables[0].Rows.Count > 0) //{ // if (Convert.ToInt32(returnDataset.Tables[0].Rows[0]["Flowprocedureid"]) == procedure.ProcedureID) // { // return "【此条码生产数据已被修改,请重开画面后再扫描】"; // } //} if (returnDataset == null || returnDataset.Tables.Count == 0 || returnDataset.Tables[0].Rows.Count == 0 || Convert.ToInt32(returnDataset.Tables[0].Rows[0]["Flowprocedureid"]) == procedure.ProcedureID ) { return "【此条码生产数据已被修改,请重新扫描此条码】"; } // 判定次品时,在产表中已经没有条码数据 modify by chenxy 2017-07-03 end } #endregion // 查询新插入的生产数据ID string sql = "select SEQ_PM_ProductionData_ID.nextval from dual"; string idStr = oracleTrConn.GetSqlResultToStr(sql); int productionDataID = 0; if (!string.IsNullOrEmpty(idStr)) { productionDataID = int.Parse(idStr); } else { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } int? ClassesSettingID = null;//班次配置ID #region 添加生产者数据 errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo, ref ClassesSettingID); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 添加生产数据 #region 属性赋值 productionData.ClassesSettingID = ClassesSettingID; productionData.ProductionDataID = Convert.ToInt32(idStr); productionData.CentralizedBatchNo = centralizedBatchNo; productionData.ProductionLineID = procedure.ProductionLineID; productionData.ProductionLineCode = procedure.ProductionlineCode; productionData.ProductionLineName = procedure.ProductionlineName; productionData.CompleteProcedureID = procedure.ProcedureID; productionData.ProcedureCode = procedure.ProcedureCode; productionData.ProcedureName = procedure.ProcedureName; productionData.ProcedureModel = procedure.ProcedureModel; productionData.ModelType = procedure.ModelType; productionData.NodeType = procedure.NodeType; productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, productionData.Barcode); // 重烧 if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.ReFire) { //productionData.GoodsLevelID = null; //productionData.IsReFire = (int)Constant.GoodsLevelType.ReFire; productionData.IsReFire = (int)Constant.ReFireFlag.No;//产品分级的时候,并不标记,走过重烧第一个结点之后,更新此字段 } // 次品 else if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Reject) { //productionData.GoodsLevelID = null; substandardFlag = true; } // 查询新插入的生产数据ID //if (productionData.GoodsLevelTypeID != (int)Constant.GoodsLevelType.ReFire) // { //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态 //string sqlReFire = "select * from tp_PM_ProductionData where ProductionData=(select max(ProductionDataid) from ProductionData where barcode=" + productionData.Barcode + " and ProcedureID=" + productionData.ProcedureID + ")"; //if (productionData.GoodsLevelTypeID != (int)Constant.GoodsLevelType.ReFire) // { ////// string sqlReFire = @"select ////// isrefire ////// from tp_pm_inproduction where barcode=:barcode ////// union ////// select ////// isrefire ////// from TP_PM_InProductionTrash where barcode=:barcode ////// "; ////// OracleParameter[] ReFireparas = new OracleParameter[] { ////// new OracleParameter(":barcode", productionData.Barcode), ////// }; ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas); ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0) ////// { ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]); ////// } // } productionData.OrganizationID = procedure.OrganizationID; productionData.GoodsID = goodsID; productionData.GoodsCode = goodsCode; productionData.GoodsName = goodsName; productionData.GoodsLevelID = productionData.GoodsLevelID; productionData.GoodsLevelTypeID = productionData.GoodsLevelTypeID; //if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Reject) //{ // productionData.GoodsEnding = Constant.GoodsLevelType.Reject.GetHashCode().ToString(); //} //else //{ // productionData.GoodsEnding = null; //} #endregion string OutSpecialRepairflag = "0";//干补标识 //errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); errMsg = AddFinishCheckProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion //#region 添加生产者数据 //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} //#endregion #region 条码有缺陷 #region 是次品 添加废弃产品 string ResponProcedureidStr = ""; if (substandardFlag) { #region 修改在产产品数据的当前工序,防止直接报损在产工序没有改过来,记录的是上一个工序 string updateInInProductionForScrap = @"Update tp_pm_inproduction set FlowProcedureID=:flowProcedureID,ProcedureID=:flowProcedureID where barcode=:barcode"; List paras = new List(); paras.Add(new OracleParameter(":barcode", productionData.Barcode)); paras.Add(new OracleParameter(":flowProcedureID", procedure.ProcedureID)); oracleTrConn.ExecuteNonQuery(updateInInProductionForScrap, paras.ToArray()); #endregion #region 添加废弃产品 ScrapProductEntity scrapProduct = new ScrapProductEntity(); #region 属性赋值 scrapProduct.BarCode = productionData.Barcode; scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode(); scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode(); scrapProduct.ScrapDate = accountDate; scrapProduct.Rreason = Constant.SCRAPTYPE_SUBSTANDARD; scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode(); scrapProduct.Auditor = sUserInfo.UserID; scrapProduct.AuditlDate = accountDate; scrapProduct.AccountDate = accountDate; scrapProduct.GoodsLevelID = productionData.GoodsLevelID; scrapProduct.GoodsLevelTypeID = productionData.GoodsLevelTypeID; scrapProduct.IsPublicBody = productionData.IsPublicBody; // 查询新插入的废弃ID string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.nextval from dual"; ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql); scrapProduct.ScrapProductID = Convert.ToInt32(ResponProcedureidStr); scrapProduct.ScrapType = 1; scrapProduct.IsQualityStatistics = 1;//新加的,因为这个报损方法是共通的,用于区别是哪里传进去的 scrapProduct.ProductionDataID = productionData.ProductionDataID; #endregion if (!RejectToReject) //不是次品到次品 wangxin 20150417 { // 保存报废 errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo); } else { // 保存报废 errMsg = AddScrapProductRejectToReject(oracleTrConn, scrapProduct, sUserInfo); } //不是次品到次品 wangxin 20150417 // 保存失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion // 存在缺陷 插入缺陷表 if (productionData.ProductionDefects != null) { foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects) { #region 保存缺陷 productionDefect.ProductionDataID = productionDataID; productionDefect.BarCode = productionData.Barcode; productionDefect.ProductionLineID = procedure.ProductionLineID; productionDefect.ProductionLineCode = procedure.ProductionlineCode; productionDefect.ProductionLineName = procedure.ProductionlineName; productionDefect.ProcedureID = procedure.ProcedureID; productionDefect.ProcedureCode = procedure.ProcedureCode; productionDefect.ProcedureName = procedure.ProcedureName; productionDefect.UserID = productionData.UserID; productionDefect.UserCode = productionData.UserCode; productionDefect.UserName = productionData.UserName; productionDefect.GoodsID = productionData.GoodsID; productionDefect.GoodsCode = productionData.GoodsCode; productionDefect.GoodsName = productionData.GoodsName; productionData.Remarks = productionData.Remarks; productionDefect.ScrapResponFlag = string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag; // 保存缺陷 errMsg = AddDefect(oracleTrConn, productionDefect, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 是次品 添加废弃责任工序 if (substandardFlag) { //if (productionDefect.DefectProcedureID != null) { #region 添加责任工序 ResponProcedureEntity responProce = new ResponProcedureEntity(); //// 查询新插入的废弃ID //string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.Currval from dual"; //string ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql); #region 属性赋值 responProce.BarCode = productionData.Barcode; responProce.ProductionDataID = productionDataID; responProce.ProductionLineID = productionDefect.ProductionLineID; responProce.ProductionLineCode = productionDefect.ProductionLineCode; responProce.ProductionLineName = productionDefect.ProductionLineName; responProce.ProcedureID = productionDefect.DefectProcedureID; responProce.ProcedureCode = productionDefect.DefectProcedureCode; responProce.ProcedureName = productionDefect.DefectProcedureName; responProce.UserID = productionDefect.DefectUserID; responProce.UserCode = productionDefect.DefectUserCode; responProce.UserName = productionDefect.DefectUserName; responProce.Remarks = productionDefect.Remarks; responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr); #endregion // 保存责任工序 errMsg = AddResponProcedure(oracleTrConn, responProce, productionDefect, sUserInfo); // 保存失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } } #endregion } } #endregion #region 条码是次品 删除在产产品数据 if (substandardFlag) { #region 删除在产产品数据 InProductionEntity delInProductionEntity = new InProductionEntity(); delInProductionEntity.BarCode = productionData.Barcode; delInProductionEntity.CompleteProcedureID = procedure.ProcedureID; delInProductionEntity.ProductionDataID = productionDataID; delInProductionEntity.GoodsLevelID = productionData.GoodsLevelID; delInProductionEntity.GoodsLevelTypeID = productionData.GoodsLevelTypeID; // 执行删除 在产数据 errMsg = DeletePDAInProduction(oracleTrConn, delInProductionEntity, false, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion #region 条码不是次品 if (!substandardFlag) { #region 中间工序/重烧 修改在产产品数据 if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle || productionData.IsReFire == Constant.GoodsGrade.ReFire.GetHashCode()) { #region 修改在产产品数据的当前工序 InProductionEntity inProductionEntity = new InProductionEntity(); inProductionEntity.BarCode = productionData.Barcode; //流程工序 inProductionEntity.FlowProcedureID = procedure.ProcedureID; // 当前工序 //inProductionEntity.CompleteProcedureID = procedure.ProcedureID; inProductionEntity.ProcedureID = procedure.ProcedureID; //生产数据ID inProductionEntity.ProductionDataID = productionDataID; // 工序模型 inProductionEntity.ProcedureModel = procedure.ProcedureModel; // 工序类别 inProductionEntity.ModelType = procedure.ModelType; // 生产工号 inProductionEntity.UserID = productionData.UserID; // 重烧 inProductionEntity.IsReFire = productionData.IsReFire; // 缺陷 inProductionEntity.DefectFlag = productionData.DefectFlag; // 产品分级 inProductionEntity.GoodsGrade = productionData.GoodsGrade; // 返工工序ID inProductionEntity.ReworkProcedureID = productionData.ReworkProcedureID; inProductionEntity.GoodsLevelID = productionData.GoodsLevelID; inProductionEntity.GoodsLevelTypeID = productionData.GoodsLevelTypeID; inProductionEntity.IsPublicBody = productionData.IsPublicBody; // 执行修改 errMsg = UpdateInProduction(oracleTrConn, inProductionEntity, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion #region 结束工序 添加成品数据 删除在产产品数据 else if (procedure.NodeType == (int)Constant.ProcedureNodeType.End) { #region 添加成品数据 删除在产产品数据 FinishedProductEntity finishedProduct = new FinishedProductEntity(); finishedProduct.BarCode = productionData.Barcode; errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } InProductionEntity delInProductionEntity = new InProductionEntity(); delInProductionEntity.BarCode = productionData.Barcode; // 执行删除 在产数据 errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion } #endregion } return errMsg; } /// /// 编辑后删除生产数据 /// /// 生产数据ID /// int public static string DeleteSubstandardToSubstandardByID(IDBTransaction oracleTrConn, int productionDataID, string barcode, SUserInfo sUserInfo) { int deleteRow = 0; try { string sqlString5 = @"update TP_PM_DefectMissedResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID where TP_PM_DefectMissedResponsible.Productiondefectid in ( select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID )"; string sqlString4 = @"update TP_PM_ProductionDataIn set ValueFlag=0, UpdateUserID=:UpdateUserID where TP_PM_ProductionDataIn.Productiondataid=:ProductionDataID "; string sqlString3 = @"update TP_PM_Defect set ValueFlag=0, UpdateUserID=:UpdateUserID where TP_PM_Defect.Productiondataid =:ProductionDataID"; string sqlString2 = @"update TP_PM_DefectResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID where TP_PM_DefectResponsible.Productiondefectid in ( select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID )"; string sqlString = @"update TP_PM_DefectImage set ValueFlag=0, UpdateUserID=:UpdateUserID where TP_PM_DefectImage.Productiondefectid in ( select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID )"; // string sqlScrapProduct = @"update TP_PM_ScrapProduct set ValueFlag=0 where barcode=:barcode"; string sqlScrapProduct = @"update TP_PM_ScrapProduct set ValueFlag=0, UpdateUserID=:UpdateUserID where ScrapProductID=( select max(ScrapProductID) from TP_PM_ScrapProduct where barcode=:barcode)"; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":ProductionDataID",OracleDbType.Int32, productionDataID,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), }; OracleParameter[] ScrapProductparas = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), }; deleteRow += oracleTrConn.ExecuteNonQuery(sqlString, paras); deleteRow += oracleTrConn.ExecuteNonQuery(sqlString2, paras); deleteRow += oracleTrConn.ExecuteNonQuery(sqlString3, paras); deleteRow += oracleTrConn.ExecuteNonQuery(sqlString4, paras); deleteRow += oracleTrConn.ExecuteNonQuery(sqlString5, paras); deleteRow += oracleTrConn.ExecuteNonQuery(sqlScrapProduct, ScrapProductparas); // 有错误 if (deleteRow == 0) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } return null; } catch (Exception ex) { throw ex; } } /// /// 编辑后删除生产数据 /// /// 生产数据ID /// int public static string DeleteSubstandardToOtherByID(IDBTransaction oracleTrConn, int productionDataID, string barcode, SUserInfo sUserInfo) { int deleteRow = 0; try { string sqlString5 = @"update TP_PM_DefectMissedResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID where TP_PM_DefectMissedResponsible.Productiondefectid in ( select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID )"; string sqlString4 = @"update TP_PM_ProductionDataIn set ValueFlag=0, UpdateUserID=:UpdateUserID where TP_PM_ProductionDataIn.Productiondataid=:ProductionDataID "; string sqlString3 = @"update TP_PM_Defect set ValueFlag=0, UpdateUserID=:UpdateUserID where TP_PM_Defect.Productiondataid =:ProductionDataID"; string sqlString2 = @"update TP_PM_DefectResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID where TP_PM_DefectResponsible.Productiondefectid in ( select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID )"; string sqlString = @"update TP_PM_DefectImage set ValueFlag=0, UpdateUserID=:UpdateUserID where TP_PM_DefectImage.Productiondefectid in ( select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID )"; //string sqlScrapProduct = @"update TP_PM_ScrapProduct set ValueFlag=0 where barcode=:barcode"; string sqlScrapProduct = @"update TP_PM_ScrapProduct set ValueFlag=0, UpdateUserID=:UpdateUserID where ScrapProductID=( select max(ScrapProductID) from TP_PM_ScrapProduct where barcode=:barcode)"; string sqlExist = "select 1 from tp_pm_inproduction where barcode = :barcode "; string sqlInsert = @"insert into TP_PM_InProduction ( BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, CreateTime, CreateUserID, UpdateTime, UpdateUserID, OPTimeStamp, SpecialRepairflag, FlowProcedureID, FlowProcedureTime, ProcedureID, ProcedureTime, ProductionDataID, logoid, ISREWORKFLAG, SEMICHECKID ) select BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, CreateTime, CreateUserID, UpdateTime, UpdateUserID, OPTimeStamp, SpecialRepairflag, FlowProcedureID, FlowProcedureTime, ProcedureID, ProcedureTime, ProductionDataID, logoid, ISREWORKFLAG, SEMICHECKID from TP_PM_InProductionTrash where barcode=:barcode "; string sqlDelete = @"delete from TP_PM_InProductionTrash where barcode=:barcode"; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":ProductionDataID",OracleDbType.Int32, productionDataID,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), }; OracleParameter[] ScrapProductparas = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), }; OracleParameter[] Existparas = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; deleteRow += oracleTrConn.ExecuteNonQuery(sqlString, paras); deleteRow += oracleTrConn.ExecuteNonQuery(sqlString2, paras); deleteRow += oracleTrConn.ExecuteNonQuery(sqlString3, paras); deleteRow += oracleTrConn.ExecuteNonQuery(sqlString4, paras); deleteRow += oracleTrConn.ExecuteNonQuery(sqlString5, paras); deleteRow += oracleTrConn.ExecuteNonQuery(sqlScrapProduct, ScrapProductparas); DataSet dsresult = oracleTrConn.GetSqlResultToDs(sqlExist, Existparas); if (dsresult != null && dsresult.Tables[0].Rows.Count == 0) { deleteRow += oracleTrConn.ExecuteNonQuery(sqlInsert, Existparas); } deleteRow += oracleTrConn.ExecuteNonQuery(sqlDelete, Existparas); // 有错误 if (deleteRow == 0) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } return null; } catch (Exception ex) { throw ex; } } /// /// 编辑后删除生产数据 /// /// 生产数据ID /// int public static string DeleteNormalToOtherByID(IDBTransaction oracleTrConn, int productionDataID, string barcode, SUserInfo sUserInfo) { int deleteRow = 0; try { string sqlString5 = @"update TP_PM_DefectMissedResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID where TP_PM_DefectMissedResponsible.Productiondefectid in ( select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID )"; string sqlString4 = @"update TP_PM_ProductionDataIn set ValueFlag=0, UpdateUserID=:UpdateUserID where TP_PM_ProductionDataIn.Productiondataid=:ProductionDataID "; string sqlString3 = @"update TP_PM_Defect set ValueFlag=0, UpdateUserID=:UpdateUserID where TP_PM_Defect.Productiondataid =:ProductionDataID"; string sqlString2 = @"update TP_PM_DefectResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID where TP_PM_DefectResponsible.Productiondefectid in ( select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID )"; string sqlString = @"update TP_PM_DefectImage set ValueFlag=0, UpdateUserID=:UpdateUserID where TP_PM_DefectImage.Productiondefectid in ( select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID )"; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":ProductionDataID",OracleDbType.Int32, productionDataID,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), }; deleteRow += oracleTrConn.ExecuteNonQuery(sqlString, paras); deleteRow += oracleTrConn.ExecuteNonQuery(sqlString2, paras); deleteRow += oracleTrConn.ExecuteNonQuery(sqlString3, paras); deleteRow += oracleTrConn.ExecuteNonQuery(sqlString4, paras); deleteRow += oracleTrConn.ExecuteNonQuery(sqlString5, paras); // 有错误 if (deleteRow == 0) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } return null; } catch (Exception ex) { throw ex; } } /// /// 保存条码信息 /// /// 工序ID /// 生产数据集 /// 用户基本信息 /// string public static string AddCheckBarcodePDA(int procedureID, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo) { string errMsg = ""; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { oracleTrConn.Connect(); #region 查询工序信息 ProcedureEntity procedure = GetProcedurByID(oracleTrConn, procedureID); #endregion #region 标准检验(半成品) if (procedure.ModelType == (int)Constant.ProcedureModelType.Normal) { errMsg = AddNormalCheck(oracleTrConn, procedure, productionDataEntitys, sUserInfo); } #endregion #region 成品检验 else if (procedure.ModelType == (int)Constant.ProcedureModelType.QualityStatistics) { errMsg = AddFinishCheckPDA(oracleTrConn, procedure, productionDataEntitys, sUserInfo); } #endregion #region 入窑前检验 else if (procedure.ModelType == (int)Constant.ProcedureModelType.IntoKilnCheck) { errMsg = AddIntoKilnCheck(oracleTrConn, procedure, productionDataEntitys, sUserInfo); } #endregion // 没有错误 提交事务 if (string.IsNullOrEmpty(errMsg)) { oracleTrConn.Commit(); } } catch (Exception ex) { oracleTrConn.Rollback(); throw ex; } finally { // 释放资源 if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Disconnect(); } } return errMsg; } #endregion /// /// 校验干补条码有效 /// /// 连接对象 /// 工序ID /// 条码 /// 返回的产品ID /// 返回的产品Code /// 返回的产品名称 /// 返回的注浆者ID /// string /// /// 袁新成 2015.3.27 新建 /// private static string CheckDryRepairBarcode(IDBTransaction oracleTrConn, int procedureID, string barcode, out int goodsID, out string goodsCode, out string goodsName, out string groutingUserCode, SUserInfo sUserInfo ) { try { OracleParameter[] paras = new OracleParameter[]{ new OracleParameter("in_procedureid",OracleDbType.Int32,procedureID,ParameterDirection.Input), new OracleParameter("in_barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input), new OracleParameter("out_errMsg",OracleDbType.Varchar2,2000,"",ParameterDirection.Output), new OracleParameter("out_goodsID",OracleDbType.Int32,ParameterDirection.Output), new OracleParameter("out_goodsCode",OracleDbType.Varchar2,50,"",ParameterDirection.Output), new OracleParameter("out_goodsName",OracleDbType.Varchar2,50,"",ParameterDirection.Output), new OracleParameter("out_groutingUserCode",OracleDbType.NVarchar2,50,null,ParameterDirection.Output), }; oracleTrConn.ExecStoredProcedure("pro_pm_checkdryrepairbarcode", paras); if (!"null".Equals(paras[3].Value + "")) { goodsID = Convert.ToInt32(paras[3].Value + ""); } else { goodsID = 0; } goodsCode = paras[4].Value + ""; goodsName = paras[5].Value + ""; if (!"null".Equals(paras[6].Value + "")) { groutingUserCode = paras[6].Value + ""; } else { groutingUserCode = null; } if ("null".Equals(paras[2].Value + "")) { return null; } return paras[2].Value.ToString().Replace("\\n\\r", "\n\r"); } catch (Exception ex) { throw ex; } } /// /// 干补标准计件 /// /// 数据连接对象 /// 工序对象 /// 条码信息 /// 用户基本信息 /// 返回的产品ID /// 返回的产品Code /// 返回的产品名称 /// 返回的注浆者ID /// string /// /// 袁新成 2015.3.26 新建 /// private static string AddDryRepairWorkPiece(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo, out int goodsID, out string goodsCode, out string goodsName, out string groutingUserCode, out string logoCode, out string logoName, out string groutingdate) { try { int deleteRow = 0; goodsID = Constant.INT_IS_ZERO; goodsCode = null; goodsName = null; groutingUserCode = string.Empty; //Constant.INT_IS_ZERO; // 获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); string errMsg = string.Empty; // 本批采集的批次号 string centralizedBatchNo = System.Guid.NewGuid().ToString(); // 条码信息 string logoName_Temp = ""; string logoCode_Temp = ""; string groutingdate_Temp = ""; foreach (DataRow barcodeRow in barcodeTable.Rows) { // 条码 string barcode = barcodeRow["Barcode"].ToString(); if (string.IsNullOrEmpty(barcode)) { throw new Exception("传入的条码号为空"); } // 生产工号 int workUserID = Convert.ToInt32(barcodeRow["UserID"]); // 生产工号 string workUserCode = barcodeRow["UserCode"].ToString(); //#region 校验条码有效性 //errMsg = CheckDryRepairBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} //#endregion if (procedure.CollectType == 1) { #region 校验条码有效性 errMsg = CheckDryRepairBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { logoName = ""; logoCode = ""; groutingdate = ""; return errMsg; } #endregion } else { string sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid, tp_pm_groutingdailydetail.goodscode, tp_pm_groutingdailydetail.goodsname, tp_pm_groutingdailydetail.usercode as groutingUserCode, tp_pm_groutingdailydetail.groutingdate, tp_mst_logo.logoid, tp_mst_logo.logocode, tp_mst_logo.logoname from tp_pm_groutingdailydetail left join tp_mst_logo on tp_pm_groutingdailydetail.logoid=tp_mst_logo.logoid where tp_pm_groutingdailydetail.barcode=:barcode "; OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":barcode",barcode), }; DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, paras); if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0) { goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]); goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString(); goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString(); groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString(); logoName = dsGrouting.Tables[0].Rows[0]["logoName"].ToString(); logoCode = dsGrouting.Tables[0].Rows[0]["logoCode"].ToString(); groutingdate = dsGrouting.Tables[0].Rows[0]["groutingdate"].ToString(); logoName_Temp = logoName; logoCode_Temp = logoCode; groutingdate_Temp = groutingdate; } } #region 数据处理 #region 处理废弃数据并转回收数据为在产数据 string querysql = @"select GOODSLEVELID from TP_MST_GOODSLEVEL where GOODSLEVELTYPEID=9 and ACCOUNTID=:accountid and VALUEFLAG=1"; OracleParameter[] queryparas = new OracleParameter[]{ new OracleParameter(":accountid",OracleDbType.Varchar2, sUserInfo.AccountID,ParameterDirection.Input) }; DataSet returnDs = oracleTrConn.GetSqlResultToDs(querysql, queryparas); if (returnDs == null || returnDs.Tables[0].Rows.Count == 0) { errMsg = "未设定干补等级"; logoName = ""; logoCode = ""; groutingdate = ""; return errMsg; } string goodsLevelID = returnDs.Tables[0].Rows[0][0].ToString(); //第一步,废弃数据的产品分级类别由 8损坯13不合格14不合格(返) 改为 9干补,产品分级=此账套相应的设置 /*string sqlUpdateLevelTypeString = @"update TP_PM_ScrapProduct set GOODSLEVELID=:GOODSLEVELID, GoodsLevelTypeID=9,SpecialRepairFlag=1, SpecialRepairUserID=:SpecialRepairUserID,SpecialRepairUserCode=:SpecialRepairUserCode,SpecialRepairTime=sysdate, UpdateUserID=:UpdateUserID where BarCode=:barcode and CreateTime=(select max(CreateTime) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1) and ValueFlag=1 and GoodsLevelTypeID=(select max(GoodsLevelTypeID) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1) "; */ // and ValueFlag=1 and GoodsLevelTypeID=8 "; string sqlUpdateLevelTypeString = @"update TP_PM_ScrapProduct set GOODSLEVELID=:GOODSLEVELID, GoodsLevelTypeID=9, SpecialRepairUserID=:SpecialRepairUserID,SpecialRepairUserCode=:SpecialRepairUserCode,SpecialRepairTime=sysdate, UpdateUserID=:UpdateUserID where BarCode=:barcode and CreateTime=(select max(CreateTime) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1) and ValueFlag=1 and GoodsLevelTypeID in (8, 13, 14) "; OracleParameter[] ScrapProductparas = new OracleParameter[]{ new OracleParameter(":GOODSLEVELID",OracleDbType.Int32,int.Parse(goodsLevelID),ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), new OracleParameter(":barcode1",OracleDbType.Varchar2, barcode,ParameterDirection.Input), new OracleParameter(":SpecialRepairUserID",OracleDbType.Int32,workUserID,ParameterDirection.Input), new OracleParameter(":SpecialRepairUserCode",OracleDbType.Varchar2,workUserCode,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), }; //modify wangx 20150623 OracleParameter[] sqlUpdateparas = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; //string sqlUpdate = "update TP_PM_InCheckedDetail set SpecialRepairFlag=1 where barcode=:barcode"; //oracleTrConn.ExecuteNonQuery(sqlUpdate, sqlUpdateparas); string sqlUpdate = "update TP_PM_ProductionDataIn set SpecialRepairFlag=1 where barcode=:barcode"; oracleTrConn.ExecuteNonQuery(sqlUpdate, sqlUpdateparas); //modify wangx 20150623 end #region //第五步,插入干补工序的生产数据(同其他计件工序),设置干补标识,产品分级类别=9干补,产品分级=此账套相应的设置 // 查询新插入的生产数据ID string sql = "select SEQ_PM_ProductionData_ID.nextval from dual"; string idStr = oracleTrConn.GetSqlResultToStr(sql); int productionDataID = 0; if (!string.IsNullOrEmpty(idStr)) { productionDataID = int.Parse(idStr); } else { logoName = ""; logoCode = ""; groutingdate = ""; return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } int? ClassesSettingID = null;//班次配置ID #region 第五步 添加生产者数据 errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID); if (!string.IsNullOrEmpty(errMsg)) { logoName = ""; logoCode = ""; groutingdate = ""; return errMsg; } #endregion ProductionDataEntity productionData = new ProductionDataEntity(); #region 属性赋值 productionData.ClassesSettingID = ClassesSettingID; productionData.ProductionDataID = Convert.ToInt32(idStr); productionData.Barcode = barcode; productionData.CentralizedBatchNo = centralizedBatchNo; productionData.ProductionLineID = procedure.ProductionLineID; productionData.ProductionLineCode = procedure.ProductionlineCode; productionData.ProductionLineName = procedure.ProductionlineName; productionData.CompleteProcedureID = procedure.ProcedureID; productionData.ProcedureCode = procedure.ProcedureCode; productionData.ProcedureName = procedure.ProcedureName; productionData.ProcedureModel = procedure.ProcedureModel; productionData.ModelType = procedure.ModelType; productionData.NodeType = procedure.NodeType; productionData.DefectFlag = (int)Constant.DefectFlag.No; productionData.ReworkProcedureID = null; productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode); productionData.IsReFire = (int)Constant.ReFireFlag.No; //设置干补标识,产品分级类别=9干补 productionData.GoodsLevelTypeID = 9; productionData.GoodsLevelID = int.Parse(goodsLevelID); productionData.GoodsGrade = (int)Constant.GoodsGrade.Good; productionData.OrganizationID = procedure.OrganizationID; productionData.GoodsID = goodsID; productionData.GoodsCode = goodsCode; productionData.GoodsName = goodsName; productionData.UserID = workUserID; productionData.UserCode = barcodeRow["UserCode"].ToString(); productionData.UserName = barcodeRow["UserName"].ToString(); productionData.PieceType = procedure.PieceType; if (barcodeRow["LogoID"].ToString() != "") { productionData.LogoID = Convert.ToInt32(barcodeRow["LogoID"]); } string sqlReFire = @"select isrefire, logoid from tp_pm_inproduction where barcode=:barcode union select isrefire, logoid from TP_PM_InProductionTrash where barcode=:barcode union select isrefire, logoid from TP_PM_FinishedProduct where barcode=:barcode "; OracleParameter[] ReFireparas = new OracleParameter[] { new OracleParameter(":barcode",barcode), }; DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas); if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0) { productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]); } if (dsReFire.Tables[0].Rows[0]["logoid"].ToString() != "") { productionData.LogoID = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["LogoID"]); } } #endregion 属性赋值 string OutSpecialRepairflag = "0";//干补标识 productionData.SpecialRepairflag = 1; errMsg = AddDryRepairProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); if (!string.IsNullOrEmpty(errMsg)) { logoName = ""; logoCode = ""; groutingdate = ""; return errMsg; } #endregion //第二步,回收站中数据回到在产中,设置干补标识。 string sqlInsInProdString = @"insert into TP_PM_InProduction(BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid, ISREWORKFLAG, SEMICHECKID) select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, :PROCEDUREMODEL, :MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, :UpdateUserID, ISREFIRE, null, null, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,1,FlowProcedureID , FlowProcedureTime,:ProcedureID,sysdate,:ProductionDataID,logoid, ISREWORKFLAG, SEMICHECKID from TP_PM_InProductionTrash where barcode=:barcode "; OracleParameter[] InProductparas = new OracleParameter[]{ new OracleParameter(":UpdateUserID",OracleDbType.Int32, workUserID,ParameterDirection.Input), // new OracleParameter(":GOODSLEVELID",OracleDbType.Int32,int.Parse(goodsLevelID),ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), new OracleParameter(":ProcedureID",OracleDbType.Int32,procedure.ProcedureID,ParameterDirection.Input), new OracleParameter(":PROCEDUREMODEL",OracleDbType.Varchar2,procedure.ProcedureModel,ParameterDirection.Input), new OracleParameter(":MODELTYPE",OracleDbType.Int32,procedure.ModelType,ParameterDirection.Input), new OracleParameter(":ProductionDataID",OracleDbType.Int32,productionDataID,ParameterDirection.Input) }; //第三步,删除回收站中的条码 string sqlDelInProductTrashString = "delete from TP_PM_InProductionTrash where barcode=:barcode "; OracleParameter[] TrashProductparas = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; //第四步,更新注浆表干补标识 // string sqlUpGroutingDeilString = @"update TP_PM_GroutingDailyDetail set SpecialRepairFlag=1 // where GroutingDailyDetailID=(select GroutingDailyDetailID from TP_PM_GROUTINGPRODUCT // where barcode=:barcode)"; string sqlUpGroutingDeilString = @"update TP_PM_GroutingDailyDetail set SpecialRepairFlag=1 where barcode=:barcode"; OracleParameter[] GroutingProductparas = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; // string sqlUpCompleteString = @"update TP_PM_FINISHEDPRODUCT set SpecialRepairFlag=1 // where barcode=:barcode "; // OracleParameter[] CompleteProductparas = new OracleParameter[]{ // new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) // }; deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpdateLevelTypeString, ScrapProductparas); deleteRow += oracleTrConn.ExecuteNonQuery(sqlInsInProdString, InProductparas); deleteRow += oracleTrConn.ExecuteNonQuery(sqlDelInProductTrashString, TrashProductparas); deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpGroutingDeilString, GroutingProductparas); //deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpCompleteString, CompleteProductparas); //由于成品后,不能报损,所以这个执行去掉 // 失败 if (deleteRow == Constant.INT_IS_ZERO) { logoName = ""; logoCode = ""; groutingdate = ""; return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } #endregion //#region 第五步 添加生产者数据 //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} //#endregion //第五步,回添加生产数据 modify wangx 2015/07/20 新添加的代码 sql = "select 1 from tp_pm_productiondatain where barcode=:barcode and valueflag=1"; OracleParameter[] Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds.Tables[0].Rows.Count == 0) { // 2 生产数据恢复到在产生产数据 sql = @"insert into tp_pm_productiondatain ( ProductionDataID, BarCode, CentralizedBatchNo, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureID, ProcedureCode, ProcedureName, ProcedureModel, ModelType, PieceType, IsReworked, NodeType, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, SpecialRepairFlag, OrganizationID, GoodsID, GoodsCode, GoodsName, UserID, UserCode, UserName, ClassesSettingID, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, ReworkProcedureID, ReworkProcedureCode, ReworkProcedureName, GroutingDailyID, GroutingDailyDetailID, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingDate, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, AccountDate, SettlementFlag, AccountID, ValueFlag, CreateTime, CreateUserID, UpdateTime, UpdateUserID, OPTimeStamp, TriggerFlag, logoid, BackOutTime,BackOutUserID,BackOutUserCode ) select ProductionDataID, BarCode, CentralizedBatchNo, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureID, ProcedureCode, ProcedureName, ProcedureModel, ModelType, PieceType, IsReworked, NodeType, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, SpecialRepairFlag, OrganizationID, GoodsID, GoodsCode, GoodsName, UserID, UserCode, UserName, ClassesSettingID, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, ReworkProcedureID, ReworkProcedureCode, ReworkProcedureName, GroutingDailyID, GroutingDailyDetailID, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingDate, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, AccountDate, SettlementFlag, AccountID, ValueFlag, CreateTime, CreateUserID, UpdateTime, UpdateUserID, OPTimeStamp, 1, logoid, BackOutTime,BackOutUserID,BackOutUserCode from TP_PM_ProductionData where valueflag=1 and barcode=:barcode "; oracleTrConn.ExecuteNonQuery(sql, Paras); } //第五步,回添加生产数据 modify wangx 2015/07/20 新添加的代码 end #endregion 数据处理 } logoName = logoName_Temp; logoCode = logoCode_Temp; groutingdate = groutingdate_Temp; return errMsg; } catch (Exception ex) { throw ex; } } /// /// 添加干补生产数据 /// /// 连接对象 /// 账务日期 /// 生产数据 /// 用户基本信息 /// string /// /// 袁新成 2015.04.1 新建 /// private static string AddDryRepairProductionData(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag) { #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号 string selectSql = ""; string returnVal = ""; //这地方连了两张表,为了成检的时候,次品在次新增 selectSql = @"select GroutingDate, GroutingUserID, GroutingUserCode, GroutingNum, GroutingMouldCode, MouldCode, GroutingDailyID, GroutingDailyDetailID, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, SpecialRepairflag from tp_pm_inproduction where barcode=:barcode union select GroutingDate, GroutingUserID, GroutingUserCode, GroutingNum, GroutingMouldCode, MouldCode, GroutingDailyID, GroutingDailyDetailID, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, SpecialRepairflag from TP_PM_InProductionTrash where barcode=:barcode "; OracleParameter[] selectparas = new OracleParameter[] { new OracleParameter(":barcode",productionData.Barcode), }; DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas); if (dsGroutingProduct == null || dsGroutingProduct.Tables[0].Rows.Count == 0) { selectSql = @"select TP_PM_GroutingDaily.GroutingDate, TP_PM_GroutingDailyDetail.UserID as GroutingUserID, TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode, TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum, TP_PM_GroutingDailyDetail.GroutingMouldCode, TP_PM_GroutingDailyDetail.MouldCode, TP_PM_GroutingDailyDetail.GroutingDailyID, TP_PM_GroutingDailyDetail.GroutingDailyDetailID, TP_PM_GroutingDailyDetail.GroutingLineID, TP_PM_GroutingDailyDetail.GroutingLineCode, TP_PM_GroutingDailyDetail.GroutingLineName, TP_PM_GroutingDaily.GMouldTypeID, TP_PM_GroutingDaily.CanManyTimes, TP_PM_GroutingDailyDetail.GroutingLineDetailID, TP_PM_GroutingDailyDetail.SpecialRepairflag from TP_PM_GroutingDaily left join TP_PM_GroutingDailyDetail on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_GroutingDailyDetail.GroutingDailyID where TP_PM_GroutingDailyDetail.barcode=:barcode "; dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas); } DateTime GroutingDate = new DateTime(); int GroutingUserID = 0, GroutingNum = 0, GroutingDailyID = 0, GroutingDailyDetailID = 0, GroutingLineID = 0, GMouldTypeID = 0, CanManyTimes = 0, GroutingLineDetailID = 0, SpecialRepairflag = 0; string GroutingUserCode = "", GroutingMouldCode = "", MouldCode = "", GroutingLineCode = "", GroutingLineName = ""; if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0) { GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]); GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]); GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString(); GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]); GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString(); MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString(); GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]); GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]); GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]); GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString(); GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString(); GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]); CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]); GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]); SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]); returnVal = SpecialRepairflag.ToString(); } #endregion #region 更新窑炉窑车属性 if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4) { DataSet ds = GetDryRepairKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo); if (ds != null) { if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息 { productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]); productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString(); productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString(); productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]); productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString(); productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString(); productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString(); productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]); } } } #endregion #region SQL string sql = "insert into tp_pm_productiondataIn" + " (productiondataid," + " barcode," + " centralizedbatchno," + " productionlineid," + " productionlinecode," + " productionlinename," + " procedureid," + " procedurecode," + " procedurename," + " proceduremodel," + " modeltype," + " piecetype," + " isreworked," + " nodetype," + " ispublicbody," + " isrefire," + " organizationid," + " goodsid," + " goodscode," + " goodsname," + " userid," + " usercode," + " username," + " kilnid," + " kilncode," + " kilnname," + " kilncarid," + " kilncarcode," + " kilncarname," + " kilncarbatchno," + " kilncarposition," + " reworkprocedureid," + " reworkprocedurecode," + " reworkprocedurename," + " remarks," + " accountdate," + " accountid," + " GoodsLevelID," + " GoodsLevelTypeID," + " createuserid," + " updateuserid," + " GroutingDate," + " GroutingUserID," + " GroutingUserCode," + " GroutingNum," + " GroutingMouldCode," + " MouldCode," + "GroutingDailyID," + "GroutingDailyDetailID," + "GroutingLineID," + " GroutingLineCode," + "GroutingLineName," + "GMouldTypeID," + "CanManyTimes," + "GroutingLineDetailID," + "SpecialRepairflag," + "ClassesSettingID," + "LogoID" + ")" + " values" + " (:productiondataid," + " :barcode," + " :centralizedbatchno," + " :productionlineid," + " :productionlinecode," + " :productionlinename," + " :procedureid," + " :procedurecode," + " :procedurename," + " :proceduremodel," + " :modeltype," + " :piecetype," + " :isreworked," + " :nodetype," + " :ispublicbody," + " :isrefire," + " :organizationid," + " :goodsid," + " :goodscode," + " :goodsname," + " :userid," + " :usercode," + " :username," + " :kilnid," + " :kilncode," + " :kilnname," + " :kilncarid," + " :kilncarcode," + " :kilncarname," + " :kilncarbatchno," + " :kilncarposition," + " :reworkprocedureid," + " :reworkprocedurecode," + " :reworkprocedurename," + " :remarks," + " :accountdata," + " :accountid," + " :GoodsLevelID," + " :GoodsLevelTypeID," + " :createuserid," + " :updateuserid," + " :groutingdate," + " :groutinguserid," + " :groutingusercode," + " :groutingnum," + " :groutingmouldcode," + " :mouldcode," + ":groutingdailyid," + ":groutingdailydetailid," + ":groutinglineid," + " :groutinglinecode," + ":groutinglinename," + ":gmouldtypeid," + ":canmanytimes," + ":groutinglinedetailid," + ":specialRepairflag," + ":classesSettingID," + ":logoID" + ")"; #endregion #region OracleParameter OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":productiondataid",productionData.ProductionDataID), new OracleParameter(":barcode",productionData.Barcode), new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo), new OracleParameter(":productionlineid",productionData.ProductionLineID), new OracleParameter(":productionlinecode",productionData.ProductionLineCode), new OracleParameter(":productionlinename",productionData.ProductionLineName), new OracleParameter(":procedureid",productionData.CompleteProcedureID), new OracleParameter(":procedurecode",productionData.ProcedureCode), new OracleParameter(":procedurename",productionData.ProcedureName), new OracleParameter(":proceduremodel",productionData.ProcedureModel), new OracleParameter(":modeltype",productionData.ModelType), new OracleParameter(":piecetype",productionData.PieceType), new OracleParameter(":isreworked",productionData.IsReworked), new OracleParameter(":nodetype",productionData.NodeType), new OracleParameter(":ispublicbody",productionData.IsPublicBody), new OracleParameter(":isrefire",productionData.IsReFire), new OracleParameter(":organizationid",productionData.OrganizationID), new OracleParameter(":goodsid",productionData.GoodsID), new OracleParameter(":goodscode",productionData.GoodsCode), new OracleParameter(":goodsname",productionData.GoodsName), new OracleParameter(":userid",productionData.UserID), new OracleParameter(":usercode",productionData.UserCode), new OracleParameter(":username",productionData.UserName), new OracleParameter(":kilnid",productionData.KilnID), new OracleParameter(":kilncode",productionData.KilnCode), new OracleParameter(":kilnname",productionData.KilnName), new OracleParameter(":kilncarid",productionData.KilnCarID), new OracleParameter(":kilncarcode",productionData.KilnCarCode), new OracleParameter(":kilncarname",productionData.KilnCarName), new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo), new OracleParameter(":kilncarposition",productionData.KilnCarPosition), new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID), new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode), new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName), new OracleParameter(":remarks",productionData.Remarks), new OracleParameter(":accountdata",accountDate), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID), new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":groutingdate",GroutingDate), new OracleParameter(":groutinguserid",GroutingUserID), new OracleParameter(":groutingusercode",GroutingUserCode), new OracleParameter(":groutingnum",GroutingNum), new OracleParameter(":groutingmouldcode",GroutingMouldCode), new OracleParameter(":mouldcode",MouldCode), new OracleParameter(":groutingdailyid",GroutingDailyID), new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID), new OracleParameter(":groutinglineid",GroutingLineID), new OracleParameter(":groutinglinecode",GroutingLineCode), new OracleParameter(":groutinglinename",GroutingLineName), new OracleParameter(":gmouldtypeid",GMouldTypeID), new OracleParameter(":canmanytimes",CanManyTimes), new OracleParameter(":groutinglinedetailid",GroutingLineDetailID), new OracleParameter(":specialRepairflag",productionData.SpecialRepairflag), new OracleParameter(":classesSettingID",productionData.ClassesSettingID), new OracleParameter(":logoID",productionData.LogoID), }; #endregion foreach (OracleParameter para in paras) { if (string.IsNullOrEmpty(para.Value + "")) { para.Value = DBNull.Value; } } int result = oracleTrConn.ExecuteNonQuery(sql, paras); OutSpecialRepairflag = returnVal; // 失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 成功返回null return null; } /// /// 根据最大生产数据ID,获取窑车窑炉等信息 /// /// /// /// /// private static DataSet GetDryRepairKilnCarInfo(IDBTransaction oracleTrConn, string barcode, SUserInfo sUserInfo) { // string sql = @"select * from tp_pm_productiondata where Productiondataid= // ( // select nvl(max(Productiondataid),0) Productiondataid from tp_pm_productiondata where barcode=:barcode // )"; string sql = @"select KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, to_char(KilnCarBatchNo) as KilnCarBatchNo, KilnCarPosition from tp_pm_inproduction where barcode=:barcode union select KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, to_char(KilnCarBatchNo) as KilnCarBatchNo, KilnCarPosition from TP_PM_InProductionTrash where barcode=:barcode "; try { IDataParameter[] paras = new OracleParameter[] { new OracleParameter(":barcode", OracleDbType.Varchar2, barcode, ParameterDirection.Input), }; DataSet returnDs = oracleTrConn.GetSqlResultToDs(sql, paras); if (returnDs != null && returnDs.Tables.Count > Constant.INT_IS_ZERO && returnDs.Tables[0].Rows.Count > Constant.INT_IS_ZERO) { return returnDs; } else { sql = @"select KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, to_char(KilnCarBatchNo) as KilnCarBatchNo, KilnCarPosition from TP_PM_FINISHEDPRODUCT where barcode=:barcode"; returnDs = oracleTrConn.GetSqlResultToDs(sql, paras); if (returnDs != null && returnDs.Tables.Count > Constant.INT_IS_ZERO && returnDs.Tables[0].Rows.Count > Constant.INT_IS_ZERO) { return returnDs; } else { return null; } } } catch (Exception ex) { throw ex; } } /// /// 更新漏扫的成型工号 /// /// 成型工号 /// 漏扫ID /// 用户基本信息 /// int public static int UpdateGroutingUserCodeByMissingID(string groutingUserCode, int missingID, SUserInfo sUserInfo) { int UpdateRow = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { oracleTrConn.Connect(); //string sql = "select userid from tp_mst_user where usercode=:usercode and valueflag=1 and isworker=1 and accountid=:accountid"; //OracleParameter[] paras = new OracleParameter[]{ // new OracleParameter(":usercode",OracleDbType.Varchar2, groutingUserCode,ParameterDirection.Input), // new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input), //}; //DataSet returnDataset = oracleTrConn.GetSqlResultToDs(sql, paras); //if (returnDataset != null && returnDataset.Tables[0].Rows.Count == 0) //{ // oracleTrConn.Commit(); // UpdateRow = -1; // return UpdateRow;//成型工号无效 //} // 20150605 wangxin begin string[] subGroutingUserCode = groutingUserCode.Trim(',').Split(','); bool isError = false; int FirstUserID = 0; string sql = ""; OracleParameter[] paras = null; DataSet returnDataset = null; for (int i = 0; i < subGroutingUserCode.Length; i++) { sql = "select userid from tp_mst_user where usercode=:usercode and valueflag=1 and isworker=1 and accountid=:accountid"; paras = new OracleParameter[]{ new OracleParameter(":usercode",OracleDbType.Varchar2, subGroutingUserCode[i],ParameterDirection.Input), new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input), }; returnDataset = oracleTrConn.GetSqlResultToDs(sql, paras); if (returnDataset != null && returnDataset.Tables[0].Rows.Count == 0) { isError = true; break; } if (i == 0) { FirstUserID = Convert.ToInt32(returnDataset.Tables[0].Rows[0]["userid"]); } } if (isError) { oracleTrConn.Commit(); UpdateRow = -1; return UpdateRow;//成型工号无效 } // 20150605 wangxin end sql = "update TP_PM_BarCodeMissing set Missuserid=:Missuserid, Missusercode=:Missusercode where missid=:missid"; paras = new OracleParameter[]{ //new OracleParameter(":Missuserid",OracleDbType.Int32,Convert.ToInt32(returnDataset.Tables[0].Rows[0]["userid"]),ParameterDirection.Input), new OracleParameter(":Missuserid",OracleDbType.Int32,FirstUserID,ParameterDirection.Input), new OracleParameter(":Missusercode", OracleDbType.Varchar2, groutingUserCode.Trim(','), ParameterDirection.Input), new OracleParameter(":missid", OracleDbType.Int32, missingID, ParameterDirection.Input), }; UpdateRow = oracleTrConn.ExecuteNonQuery(sql, paras); if (UpdateRow > 0) { oracleTrConn.Commit(); } else { oracleTrConn.Rollback(); } } catch (Exception ex) { oracleTrConn.Rollback(); throw ex; } finally { // 释放资源 if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Disconnect(); } } return UpdateRow; } /// /// 在入窑工序检验窑车号是否存在 /// /// 窑车编码 /// 工序ID /// 用户基本信息 /// public static int CheckKilnCarByIntoCar(string kilncarcode, int procedureid, SUserInfo sUserInfo) { int UpdateRow = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { oracleTrConn.Connect(); // 判断窑车编码是否有效 string sql = "select kilncarid from tp_mst_kilncar where kilncarcode=:kilncarcode and valueflag=1 and accountid=:accountid"; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":kilncarcode",OracleDbType.Varchar2, kilncarcode,ParameterDirection.Input), new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input), }; DataSet dsExists = oracleTrConn.GetSqlResultToDs(sql, paras); int kilncarid = 0; if (dsExists != null && dsExists.Tables[0].Rows.Count == 0) { oracleTrConn.Commit(); UpdateRow = -99; return UpdateRow;//窑车编码无效 } kilncarid = Convert.ToInt32(dsExists.Tables[0].Rows[0]["kilncarid"]);//窑车ID //判断此窑车号有无产品 sql = "select barcode,KilnCarBatchNo from TP_PM_KilnCarGoods where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1"; paras = new OracleParameter[]{ new OracleParameter(":KilnCarID",OracleDbType.Int32, kilncarid,ParameterDirection.Input), new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input), }; DataSet dsGoods = oracleTrConn.GetSqlResultToDs(sql, paras); if (dsGoods != null && dsGoods.Tables[0].Rows.Count == 0) { oracleTrConn.Commit(); UpdateRow = -98; return UpdateRow;//窑车己无产品 } // 判断窑车编码是否在入窑工序 sql = "select 1 from TP_PM_InProduction where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1 and FlowProcedureID=:FlowProcedureID"; paras = new OracleParameter[]{ new OracleParameter(":KilnCarID",OracleDbType.Int32, kilncarid,ParameterDirection.Input), new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input), new OracleParameter(":FlowProcedureID", OracleDbType.Int32, procedureid, ParameterDirection.Input), }; dsExists = oracleTrConn.GetSqlResultToDs(sql, paras); if (dsExists != null && dsExists.Tables[0].Rows.Count == 0) { oracleTrConn.Commit(); UpdateRow = -97; return UpdateRow;//窑车号没有入窑,不可以撤销 } int KilnCarDataID = 0;//窑车生产数据ID string KilnCarBatchNo = ""; // 遍历窑车产品 bool isError = false;//默认没有错误 for (int i = 0; i < dsGoods.Tables[0].Rows.Count; i++) { #region 先查询生产数据最后3条 string sqlString = @"select ProductionDataID, ProcedureID, ProcedureModel, ModelType, ReworkProcedureID, UserID from (select ProductionDataID, ProcedureID, ProcedureModel, ModelType, ReworkProcedureID, UserID from Tp_Pm_ProductiondataIn where barcode = :barcode and valueflag = 1 and ModelType<>1 and ModelType<>2 order by ProductionDataID desc) where rownum <=1";//where rownum <=3"; paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input), }; DataSet productionData = oracleTrConn.GetSqlResultToDs(sqlString, paras); if (productionData == null || productionData.Tables.Count == Constant.INT_IS_ZERO || productionData.Tables[0].Rows.Count != Constant.INT_IS_ONE) { //errMsg = Messages.MSG_PM_W016; isError = true; break; } #endregion #region 回滚在产数据 sqlString = @"update TP_PM_InProduction set FlowProcedureID = :flowProcedureID, ProcedureModel = :procedureModel, ProcedureID = :flowProcedureID, ModelType = :modelType, ReworkProcedureID = :reworkProcedureID, UserID = :userID, updateuserid = :updateuserid where barcode = :barcode"; paras = new OracleParameter[]{ new OracleParameter(":flowProcedureID",OracleDbType.Int32, productionData.Tables[0].Rows[0]["ProcedureID"],ParameterDirection.Input),//2-->1 new OracleParameter(":procedureModel",OracleDbType.Int32, productionData.Tables[0].Rows[0]["procedureModel"],ParameterDirection.Input), new OracleParameter(":modelType",OracleDbType.Int32, productionData.Tables[0].Rows[0]["modelType"],ParameterDirection.Input), new OracleParameter(":reworkProcedureID",OracleDbType.Int32, productionData.Tables[0].Rows[0]["reworkProcedureID"],ParameterDirection.Input), new OracleParameter(":userID",OracleDbType.Int32, productionData.Tables[0].Rows[0]["userID"],ParameterDirection.Input), new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input), }; UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras); if (UpdateRow == Constant.INT_IS_ZERO) { // 保存失败 isError = true; break; } #endregion #region 删除生产者和最后一条生产数据 //sqlString = "delete TP_PM_Producer where ProductionDataID=:productionDataID"; paras = new OracleParameter[]{ new OracleParameter(":productionDataID",OracleDbType.Int32, productionData.Tables[0].Rows[0]["productionDataID"],ParameterDirection.Input), //new OracleParameter(":productionDataID2",OracleDbType.Int32, // productionData.Tables[0].Rows[0]["productionDataID"],ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input), }; //modify 2015/05/13 wangx GoodsLevelTypeID=12 撤销入窑 sqlString = "select GoodsLevelID,GoodsLevelName,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=12 and AccountID=" + sUserInfo.AccountID + " and ValueFlag=1"; DataSet dsGoodsLevel = oracleTrConn.GetSqlResultToDs(sqlString, null); int? GoodsLevelID = null; if (dsGoodsLevel != null && dsGoodsLevel.Tables[0].Rows.Count > 0) { GoodsLevelID = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelID"]); } //modify end sqlString = "update TP_PM_ProductionDataIn set valueflag=0 ,updateuserid=" + sUserInfo.UserID; if (GoodsLevelID != null) { sqlString += ",GoodsLevelID=" + GoodsLevelID; sqlString += ",GoodsLevelTypeID=12"; } //sqlString += " where ProductionDataID=:productionDataID or ProductionDataID=:productionDataID2"; sqlString += " where barcode=:barcode and ProductionDataID>:productionDataID "; //or ProductionDataID=:productionDataID2 UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras); if (UpdateRow == Constant.INT_IS_ZERO) { // 保存失败 isError = true; break; } #endregion #region 删除窑车产品 sqlString = "delete TP_PM_KilnCarGoods where BarCode=:barCode"; paras = new OracleParameter[]{ new OracleParameter(":barCode",OracleDbType.Varchar2, dsGoods.Tables[0].Rows[i]["barcode"],ParameterDirection.Input), }; UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras); if (UpdateRow == Constant.INT_IS_ZERO) { // 保存失败 isError = true; break; } #endregion #region 读取窑车生产数据,进行撤销 sql = @"select KilnCarDataID, ProductionLineID,ProcedureID, ProcedureCode,ProcedureName,ProcedureModel,ModelType,PieceType from TP_PM_KilnCarData where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1 and KilnCarBatchNo=:KilnCarBatchNo order by KilnCarDataID "; paras = new OracleParameter[]{ new OracleParameter(":KilnCarID",OracleDbType.Int32, kilncarid,ParameterDirection.Input), new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input), new OracleParameter(":KilnCarBatchNo",OracleDbType.Varchar2, dsGoods.Tables[0].Rows[i]["KilnCarBatchNo"].ToString(),ParameterDirection.Input), }; KilnCarBatchNo = dsGoods.Tables[0].Rows[i]["KilnCarBatchNo"].ToString(); dsExists = oracleTrConn.GetSqlResultToDs(sql, paras); if (dsExists != null && dsExists.Tables[0].Rows.Count > 0) { //最后窑车生产数据ID赋值 撤二步骤 KilnCarDataID = Convert.ToInt32(dsExists.Tables[0].Rows[0]["KilnCarDataID"]); sqlString = @"update TP_PM_KilnCarStatus set ProductionLineID=:ProductionLineID ,ProcedureID=:ProcedureID ,ProcedureCode=:ProcedureCode ,ProcedureName=:ProcedureName ,ProcedureModel=:ProcedureModel ,ModelType=:ModelType ,PieceType=:PieceType ,KilnCarStatus=0,LoadingTime=null,IntoKilnTime=null,OutKilnTime=null,UnloadingTime=null where KilnCarID=:KilnCarID"; paras = new OracleParameter[]{ new OracleParameter(":ProductionLineID",OracleDbType.Int32, dsExists.Tables[0].Rows[0]["ProductionLineID"],ParameterDirection.Input), new OracleParameter(":ProcedureID",OracleDbType.Int32, dsExists.Tables[0].Rows[0]["ProcedureID"],ParameterDirection.Input), new OracleParameter(":ProcedureCode",OracleDbType.Varchar2, dsExists.Tables[0].Rows[0]["ProcedureCode"].ToString(),ParameterDirection.Input), new OracleParameter(":ProcedureModel",OracleDbType.Varchar2, dsExists.Tables[0].Rows[0]["ProcedureModel"].ToString(),ParameterDirection.Input), new OracleParameter(":ModelType",OracleDbType.Int32, Convert.ToInt32(dsExists.Tables[0].Rows[0]["ModelType"]),ParameterDirection.Input), new OracleParameter(":PieceType",OracleDbType.Varchar2, dsExists.Tables[0].Rows[0]["PieceType"].ToString(),ParameterDirection.Input), new OracleParameter(":KilnCarID",OracleDbType.Int32, kilncarid,ParameterDirection.Input), new OracleParameter(":ProcedureName",OracleDbType.Varchar2, dsExists.Tables[0].Rows[0]["ProcedureName"].ToString(),ParameterDirection.Input), }; UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras); if (UpdateRow == Constant.INT_IS_ZERO) { // 保存失败 isError = true; break; } } #endregion } //modify wangx 20150606 begin string updateSql = "update TP_PM_KilnCarData set valueflag=0,UpdateUserID=" + sUserInfo.UserID + " where KilnCarDataID>=" + KilnCarDataID + " and KilnCarBatchNo=" + KilnCarBatchNo; int row = oracleTrConn.ExecuteNonQuery(updateSql); //modify wangx 20150606 end if (isError) //有错误消息 { UpdateRow = -1;//失败 oracleTrConn.Rollback(); } else { UpdateRow = 1;//成功 oracleTrConn.Commit(); } } catch (Exception ex) { oracleTrConn.Rollback(); throw ex; } finally { // 释放资源 if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Disconnect(); } } return UpdateRow; } /// /// 在入窑工序检验窑车号是否存在 /// /// 窑车编码 /// 工序ID /// 用户基本信息 /// public static int CheckKilnCarByIntoCar2(string kilncarcode, int procedureid, SUserInfo sUserInfo) { int UpdateRow = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { oracleTrConn.Connect(); // 判断窑车编码是否有效 string sql = "select kilncarid from tp_mst_kilncar where kilncarcode=:kilncarcode and valueflag=1 and accountid=:accountid"; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":kilncarcode",OracleDbType.Varchar2, kilncarcode,ParameterDirection.Input), new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input), }; DataSet dsExists = oracleTrConn.GetSqlResultToDs(sql, paras); int kilncarid = 0; if (dsExists != null && dsExists.Tables[0].Rows.Count == 0) { oracleTrConn.Commit(); UpdateRow = -99; return UpdateRow;//窑车编码无效 } kilncarid = Convert.ToInt32(dsExists.Tables[0].Rows[0]["kilncarid"]);//窑车ID //判断此窑车号有无产品 sql = "select barcode,KilnCarBatchNo from TP_PM_KilnCarGoods where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1"; paras = new OracleParameter[]{ new OracleParameter(":KilnCarID",OracleDbType.Int32, kilncarid,ParameterDirection.Input), new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input), }; DataSet dsGoods = oracleTrConn.GetSqlResultToDs(sql, paras); if (dsGoods != null && dsGoods.Tables[0].Rows.Count == 0) { oracleTrConn.Commit(); UpdateRow = -98; return UpdateRow;//窑车己无产品 } // 判断窑车编码是否在入窑工序 sql = "select 1 from TP_PM_InProduction where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1 and FlowProcedureID=:FlowProcedureID"; paras = new OracleParameter[]{ new OracleParameter(":KilnCarID",OracleDbType.Int32, kilncarid,ParameterDirection.Input), new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input), new OracleParameter(":FlowProcedureID", OracleDbType.Int32, procedureid, ParameterDirection.Input), }; dsExists = oracleTrConn.GetSqlResultToDs(sql, paras); if (dsExists != null && dsExists.Tables[0].Rows.Count == 0) { oracleTrConn.Commit(); UpdateRow = -97; return UpdateRow;//窑车号没有入窑,不可以撤销 } int KilnCarDataID = 0;//窑车生产数据ID // 遍历窑车产品 bool isError = false;//默认没有错误 for (int i = 0; i < dsGoods.Tables[0].Rows.Count; i++) { #region 先查询生产数据最后3条 string sqlString = @"select ProductionDataID, ProcedureID, ProcedureModel, ModelType, ReworkProcedureID, UserID, logoid from (select ProductionDataID, ProcedureID, ProcedureModel, ModelType, ReworkProcedureID, UserID, logoid from Tp_Pm_ProductiondataIn where barcode = :barcode and valueflag = 1 and ModelType<>2 order by ProductionDataID desc) where rownum <=1"; paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input), }; DataSet productionData = oracleTrConn.GetSqlResultToDs(sqlString, paras); if (productionData == null || productionData.Tables.Count == Constant.INT_IS_ZERO || productionData.Tables[0].Rows.Count != Constant.INT_IS_ONE) { //errMsg = Messages.MSG_PM_W016; isError = true; break; } #endregion #region 回滚在产数据 sqlString = @"update TP_PM_InProduction set FlowProcedureID = :flowProcedureID, ProcedureModel = :procedureModel, ProcedureID = :flowProcedureID, ModelType = :modelType, ReworkProcedureID = :reworkProcedureID, UserID = :userID, updateuserid = :updateuserid, logoid = :logoid where barcode = :barcode"; paras = new OracleParameter[]{ new OracleParameter(":flowProcedureID",OracleDbType.Int32, productionData.Tables[0].Rows[0]["ProcedureID"],ParameterDirection.Input),//2-->1 new OracleParameter(":procedureModel",OracleDbType.Int32, productionData.Tables[0].Rows[0]["procedureModel"],ParameterDirection.Input), new OracleParameter(":modelType",OracleDbType.Int32, productionData.Tables[0].Rows[0]["modelType"],ParameterDirection.Input), new OracleParameter(":reworkProcedureID",OracleDbType.Int32, productionData.Tables[0].Rows[0]["reworkProcedureID"],ParameterDirection.Input), new OracleParameter(":userID",OracleDbType.Int32, productionData.Tables[0].Rows[0]["userID"],ParameterDirection.Input), new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input), new OracleParameter(":logoid",OracleDbType.Int32, productionData.Tables[0].Rows[0]["logoid"].ToString()==""?null:productionData.Tables[0].Rows[0]["logoid"],ParameterDirection.Input), }; UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras); if (UpdateRow == Constant.INT_IS_ZERO) { // 保存失败 isError = true; break; } #endregion #region 删除生产者和最后一条生产数据 //sqlString = "delete TP_PM_Producer where ProductionDataID=:productionDataID"; paras = new OracleParameter[]{ new OracleParameter(":productionDataID",OracleDbType.Int32, productionData.Tables[0].Rows[0]["productionDataID"],ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input), }; //modify 2015/05/13 wangx GoodsLevelTypeID=12 撤销入窑 sqlString = "select GoodsLevelID,GoodsLevelName,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=12 and AccountID=" + sUserInfo.AccountID + " and ValueFlag=1"; DataSet dsGoodsLevel = oracleTrConn.GetSqlResultToDs(sqlString, null); int? GoodsLevelID = null; if (dsGoodsLevel != null && dsGoodsLevel.Tables[0].Rows.Count > 0) { GoodsLevelID = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelID"]); } //modify end sqlString = "update TP_PM_ProductionDataIn set valueflag=0,updateuserid= " + sUserInfo.UserID; if (GoodsLevelID != null) { sqlString += ",GoodsLevelID=" + GoodsLevelID; sqlString += ",GoodsLevelTypeID=12"; } //sqlString += " where ProductionDataID=:productionDataID or ProductionDataID=:productionDataID2"; sqlString += " where barcode=:barcode and ProductionDataID>:productionDataID "; //or ProductionDataID=:productionDataID2 UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras); if (UpdateRow == Constant.INT_IS_ZERO) { // 保存失败 isError = true; break; } #endregion //#region 删除窑车产品 //sqlString = "delete TP_PM_KilnCarGoods where BarCode=:barCode"; //paras = new OracleParameter[]{ // new OracleParameter(":barCode",OracleDbType.Varchar2, // dsGoods.Tables[0].Rows[i]["barcode"],ParameterDirection.Input), //}; //UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras); //if (UpdateRow == Constant.INT_IS_ZERO) //{ // // 保存失败 // isError = true; // break; //} //#endregion #region 读取窑车生产数据,进行撤销 sql = @"select KilnCarDataID, ProductionLineID,ProcedureID, ProcedureCode,ProcedureName,ProcedureModel,ModelType,PieceType from TP_PM_KilnCarData where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1 and KilnCarBatchNo=:KilnCarBatchNo order by KilnCarDataID "; paras = new OracleParameter[]{ new OracleParameter(":KilnCarID",OracleDbType.Int32, kilncarid,ParameterDirection.Input), new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input), new OracleParameter(":KilnCarBatchNo",OracleDbType.Varchar2, dsGoods.Tables[0].Rows[i]["KilnCarBatchNo"].ToString(),ParameterDirection.Input), }; dsExists = oracleTrConn.GetSqlResultToDs(sql, paras); if (dsExists != null && dsExists.Tables[0].Rows.Count > 0) { //最后窑车生产数据ID赋值 KilnCarDataID = Convert.ToInt32(dsExists.Tables[0].Rows[dsExists.Tables[0].Rows.Count - 1]["KilnCarDataID"]); sqlString = @"update TP_PM_KilnCarStatus set ProductionLineID=:ProductionLineID ,ProcedureID=:ProcedureID ,ProcedureCode=:ProcedureCode ,ProcedureName=:ProcedureName ,ProcedureModel=:ProcedureModel ,ModelType=:ModelType ,PieceType=:PieceType ,KilnCarStatus=0,IntoKilnTime=null,OutKilnTime=null,UnloadingTime=null where KilnCarID=:KilnCarID"; paras = new OracleParameter[]{ new OracleParameter(":ProductionLineID",OracleDbType.Int32, dsExists.Tables[0].Rows[0]["ProductionLineID"],ParameterDirection.Input), new OracleParameter(":ProcedureID",OracleDbType.Int32, dsExists.Tables[0].Rows[0]["ProcedureID"],ParameterDirection.Input), new OracleParameter(":ProcedureCode",OracleDbType.Varchar2, dsExists.Tables[0].Rows[0]["ProcedureCode"].ToString(),ParameterDirection.Input), new OracleParameter(":ProcedureModel",OracleDbType.Varchar2, dsExists.Tables[0].Rows[0]["ProcedureModel"].ToString(),ParameterDirection.Input), new OracleParameter(":ModelType",OracleDbType.Int32, Convert.ToInt32(dsExists.Tables[0].Rows[0]["ModelType"]),ParameterDirection.Input), new OracleParameter(":PieceType",OracleDbType.Varchar2, dsExists.Tables[0].Rows[0]["PieceType"].ToString(),ParameterDirection.Input), new OracleParameter(":KilnCarID",OracleDbType.Int32, kilncarid,ParameterDirection.Input), new OracleParameter(":ProcedureName",OracleDbType.Varchar2, dsExists.Tables[0].Rows[0]["ProcedureName"].ToString(),ParameterDirection.Input), }; UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras); if (UpdateRow == Constant.INT_IS_ZERO) { // 保存失败 isError = true; break; } } #endregion } //modify wangx 20150606 begin string updateSql = "update TP_PM_KilnCarData set valueflag=0,UpdateUserID=" + sUserInfo.UserID + " where KilnCarDataID=" + KilnCarDataID; int row = oracleTrConn.ExecuteNonQuery(updateSql); //modify wangx 20150606 end if (isError) //有错误消息 { UpdateRow = -1;//失败 oracleTrConn.Rollback(); } else { UpdateRow = 1;//成功 oracleTrConn.Commit(); } } catch (Exception ex) { oracleTrConn.Rollback(); throw ex; } finally { // 释放资源 if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Disconnect(); } } return UpdateRow; } /// /// 保存盘点单 /// /// /// /// /// public static int SaveInChecked(InProductionEntity[] inProductionEntity, string remarks, SUserInfo sUserInfo) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { if (inProductionEntity[0].ReworkProcedureID == 0) { //盘点单号 string InCheckedNo = string.Format("IPC{0}", DateTime.Now.ToString("yyyyMMddHHmmss")); //获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); //备注 string Remarks = remarks; oracleTrConn.Connect(); //盘点单ID string sql = "select SEQ_PM_InChecked_ID.nextval from dual"; int InCheckedID = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sql)); #region 插入盘点单主表信息 sql = @"insert into TP_PM_InChecked ( InCheckedID, InCheckedNo, AccountDate, Remarks, AccountID, CreateUserID, UpdateUserID, INCHECKNAME ) values ( :InCheckedID, :InCheckedNo, :AccountDate, :Remarks, :AccountID, :CreateUserID, :UpdateUserID, :INCHECKNAME )"; OracleParameter[] Paras = new OracleParameter[] { new OracleParameter(":InCheckedID",OracleDbType.Int32, InCheckedID,ParameterDirection.Input), new OracleParameter(":InCheckedNo",OracleDbType.NVarchar2, InCheckedNo,ParameterDirection.Input), new OracleParameter(":AccountDate",OracleDbType.Date, accountDate,ParameterDirection.Input), new OracleParameter(":Remarks",OracleDbType.NVarchar2, Remarks,ParameterDirection.Input), new OracleParameter(":AccountID",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input), new OracleParameter(":CreateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":INCHECKNAME",OracleDbType.NVarchar2, inProductionEntity[0].CompleteProcedureName,ParameterDirection.Input), }; returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras); #endregion //string barcodes = ""; List parameters = null; //int row = 0; //foreach (InProductionEntity entity in inProductionEntity) //{ // barcodes += entity.BarCode + ","; // row++; // if (row > 15) //为了15查数据库一次 // { // barcodes = barcodes.TrimEnd(',') + '|'; // row = 0;//重置 // } //} //barcodes = barcodes.TrimEnd(','); //string[] subsplit = barcodes.Split('|'); // foreach (InProductionEntity entity in inProductionEntity)foreach (InProductionEntity entity in inProductionEntity) //foreach (string entity in subsplit) //{ //barcodes += entity.BarCode + ","; //barcodes = barcodes.TrimEnd(','); //在产产品是唯一的,直接根据条码查询,并插入到盘点明细 sql = @" insert into TP_PM_InCheckedDetail ( InCheckedID, BarCode, InCheckedNo, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureID, ProcedureTime, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, SpecialRepairFlag, GoodsLevelID, GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, CreateUserID, UpdateUserID, valueflag, logoid, ISREWORKFLAG,INSCRAPFLAG ) select :InCheckedID, inp.BarCode, :InCheckedNo, inp.ProductionLineID, inp.ProductionLineCode, inp.ProductionLineName, inp.ProcedureID, inp.ProcedureTime, inp.ProcedureModel, inp.ModelType, inp.DefectFlag, inp.ReworkProcedureID, inp.IsPublicBody, inp.IsReFire, inp.SpecialRepairFlag, inp.GoodsLevelID, inp.GoodsLevelTypeID, inp.GoodsID, inp.GoodsCode, inp.GoodsName, inp.UserID, inp.GroutingDailyID, inp.GroutingDailyDetailID, inp.GroutingDate, inp.GroutingLineID, inp.GroutingLineCode, inp.GroutingLineName, inp.GMouldTypeID, inp.CanManyTimes, inp.GroutingLineDetailID, inp.GroutingMouldCode, inp.MouldCode, inp.GroutingUserID, inp.GroutingUserCode, inp.GroutingNum, inp.Remarks, inp.KilnID, inp.KilnCode, inp.KilnName, inp.KilnCarID, inp.KilnCarCode, inp.KilnCarName, inp.KilnCarBatchNo, inp.KilnCarPosition, :AccountID, :CreateUserID, :UpdateUserID, 1, inp.logoid, inp.ISREWORKFLAG,inp.INSCRAPFLAG from TP_PM_InProduction inp LEFT JOIN tp_mst_goods g ON g.goodsid = inp.goodsid LEFT JOIN tp_mst_goodsType gt ON gt.goodstypeid = g.goodstypeid where 1=1 "; //sql += "AND instr(','||:ProcedureIDS||',',','||TP_PM_InProduction.ProcedureID||',')>0 "; parameters = new List(); // 工序IDS if (!string.IsNullOrEmpty(inProductionEntity[0].ProcedureIDS)) { sql += "AND instr(','||:ProcedureIDS||',',','||inp.FlowProcedureID||',')>0 "; parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, inProductionEntity[0].ProcedureIDS, ParameterDirection.Input)); } // 完成日期 if (inProductionEntity[0].StartCompleteDate != null) { sql = sql + " AND inp.ProcedureTime >= :Createdate AND inp.ProcedureTime <= :EndDate "; parameters.Add(new OracleParameter(":Createdate", OracleDbType.Date, inProductionEntity[0].StartCompleteDate, ParameterDirection.Input)); parameters.Add(new OracleParameter(":EndDate", OracleDbType.Date, inProductionEntity[0].EndCompleteDate, ParameterDirection.Input)); } // 编码IDS if (!string.IsNullOrEmpty(inProductionEntity[0].GoodsCodeList)) { sql += "AND instr(','||:GoodsIDS||',',','||inp.GoodsID||',')>0 "; parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, inProductionEntity[0].GoodsCodeList, ParameterDirection.Input)); } // 产品类型 if (!string.IsNullOrEmpty(inProductionEntity[0].GoodsTypeCode)) { sql += "AND instr(gt.goodstypecode, :GoodsTypeCode)=1 "; parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, inProductionEntity[0].GoodsTypeCode, ParameterDirection.Input)); } parameters.Add(new OracleParameter(":InCheckedID", OracleDbType.Int32, InCheckedID, ParameterDirection.Input)); parameters.Add(new OracleParameter(":InCheckedNo", OracleDbType.Varchar2, InCheckedNo, ParameterDirection.Input)); parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input)); parameters.Add(new OracleParameter(":CreateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input)); parameters.Add(new OracleParameter(":UpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input)); returnRows += oracleTrConn.ExecuteNonQuery(sql, parameters.ToArray()); #region 插入盘点工号列表 foreach (DataRow r in inProductionEntity[0].UserTable.Rows) { if (r["userid"] != DBNull.Value) { sql = @" Insert into tp_pm_incheckeduser ( incheckedid, userCode, userid ) values ( :inchecked, :userCode, :userid ) "; Paras = new OracleParameter[] { new OracleParameter(":inchecked",OracleDbType.Int32, InCheckedID,ParameterDirection.Input), new OracleParameter(":userCode",OracleDbType.NVarchar2, r["userCode"],ParameterDirection.Input), new OracleParameter(":userid",OracleDbType.Int32, r["userid"],ParameterDirection.Input), }; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); } } #endregion } else { string sql = @"Update TP_PM_InChecked set Incheckname=:Incheckname,Remarks=:Remarks,updateuserid=:updateuserid where InCheckedID=:InCheckedID"; OracleParameter[] Paras = new OracleParameter[] { new OracleParameter(":InCheckedID",OracleDbType.Int32, inProductionEntity[0].ReworkProcedureID,ParameterDirection.Input), new OracleParameter(":Incheckname",OracleDbType.NVarchar2, inProductionEntity[0].CompleteProcedureName,ParameterDirection.Input), new OracleParameter(":Remarks",OracleDbType.NVarchar2, remarks,ParameterDirection.Input), new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), }; returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras); sql = @"delete from tp_pm_incheckeduser where InCheckedID=:InCheckedID"; Paras = new OracleParameter[] { new OracleParameter(":InCheckedID",OracleDbType.Int32, inProductionEntity[0].ReworkProcedureID,ParameterDirection.Input), }; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); #region 插入盘点工号列表 foreach (DataRow r in inProductionEntity[0].UserTable.Rows) { if (string.IsNullOrEmpty(r["userCode"].ToString()) || string.IsNullOrEmpty(r["userid"].ToString())) { continue; } sql = @" Insert into tp_pm_incheckeduser ( incheckedid, userCode, userid ) values ( :inchecked, :userCode, :userid ) "; Paras = new OracleParameter[] { new OracleParameter(":inchecked",OracleDbType.Int32, inProductionEntity[0].ReworkProcedureID,ParameterDirection.Input), new OracleParameter(":userCode",OracleDbType.NVarchar2, r["userCode"],ParameterDirection.Input), new OracleParameter(":userid",OracleDbType.Int32, r["userid"],ParameterDirection.Input), }; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); } #endregion } if (returnRows == 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } return returnRows; } /// /// 更新盘点单 /// /// 盘点单号 /// 产品条码 /// 用户基本信息 /// public static int UpdateInChecked(int InCheckedID, string BarCode, SUserInfo sUserInfo) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { // 转换条码 string sqlString = @"select FUN_CMN_GetBarCode(:barcode,null,:accountid) From DUAL"; OracleParameter[] paras1 = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, BarCode,ParameterDirection.Input), new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input), }; BarCode = oracleTrConn.GetSqlResultToStr(sqlString, paras1); string sql = @"select 1 from TP_PM_InProduction where barcode=:barcode"; OracleParameter[] Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.NVarchar2, BarCode,ParameterDirection.Input) }; DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds != null && ds.Tables[0].Rows.Count == 0) { returnRows = -2;//该产品不在生产线 return returnRows; } sql = @"select InCheckedFlag,CHECKEDUSERID as Userid from TP_PM_InCheckedDetail where InCheckedID=:InCheckedID and BarCode=:BarCode and Valueflag=1"; Paras = new OracleParameter[] { new OracleParameter(":InCheckedID",OracleDbType.Int32, InCheckedID,ParameterDirection.Input), new OracleParameter(":BarCode",OracleDbType.NVarchar2, BarCode,ParameterDirection.Input) }; ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds != null && ds.Tables[0].Rows.Count == 0) { sql = @"select InCheckedNo from TP_PM_InChecked where InCheckedID=:InCheckedID"; Paras = new OracleParameter[] { new OracleParameter(":InCheckedID",OracleDbType.Int32, InCheckedID,ParameterDirection.Input), }; ds = oracleTrConn.GetSqlResultToDs(sql, Paras); string InCheckedNo = ds.Tables[0].Rows[0]["InCheckedNo"].ToString();//肯定会有盘点单号,所以就没有加判断 //在产不在生产线上,属于盘赢 sql = @" insert into TP_PM_InCheckedDetail ( InCheckedID, BarCode, InCheckedNo, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureID, ProcedureTime, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, SpecialRepairFlag, GoodsLevelID, GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, CreateUserID, UpdateUserID, InCheckedFlag, CheckedDate, CheckedUserID, logoid ) select :InCheckedID, BarCode, :InCheckedNo, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureID, ProcedureTime, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, SpecialRepairFlag, GoodsLevelID, GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, :AccountID, :CreateUserID, :UpdateUserID, :InCheckedFlag, sysdate, :CheckedUserID, logoid from TP_PM_InProduction where 1=1 "; ; List parameters = new List(); sql += "AND instr(','||:barcode||',',','||TP_PM_InProduction.barcode||',')>0 "; parameters.Add(new OracleParameter(":InCheckedID", OracleDbType.Int32, InCheckedID, ParameterDirection.Input)); parameters.Add(new OracleParameter(":InCheckedNo", OracleDbType.Varchar2, InCheckedNo, ParameterDirection.Input)); parameters.Add(new OracleParameter(":barcode", OracleDbType.NVarchar2, BarCode, ParameterDirection.Input)); parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input)); parameters.Add(new OracleParameter(":CreateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input)); parameters.Add(new OracleParameter(":UpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input)); parameters.Add(new OracleParameter(":InCheckedFlag", OracleDbType.Int32, Constant.InCheckedFlag.InCheckedWin.GetHashCode(), ParameterDirection.Input)); parameters.Add(new OracleParameter(":CheckedUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input)); returnRows += oracleTrConn.ExecuteNonQuery(sql, parameters.ToArray()); returnRows = 10; } else { int InCheckedFlag = Convert.ToInt32(ds.Tables[0].Rows[0]["InCheckedFlag"]); if (InCheckedFlag == 1) { if (Convert.ToInt32(ds.Tables[0].Rows[0]["Userid"]) != sUserInfo.UserID) { returnRows = -22;//己被其他工号盘点 } else { returnRows = -24;//己被自己工号盘点 } return returnRows; } else if (InCheckedFlag == 2) { if (Convert.ToInt32(ds.Tables[0].Rows[0]["Userid"]) != sUserInfo.UserID) { returnRows = -23;//己被其他工号盘盈 } else { returnRows = -25;//己被自己工号盘盈 } return returnRows; } sql = "update TP_PM_InCheckedDetail set InCheckedFlag=:InCheckedFlag,CheckedDate=sysdate,CheckedUserID=:CheckedUserID,UpdateUserID=:UpdateUserID where InCheckedID=:InCheckedID and BarCode=:BarCode and InCheckedFlag=:whereInCheckedFlag"; Paras = new OracleParameter[] { new OracleParameter(":CheckedUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":InCheckedFlag",OracleDbType.Int32, Constant.InCheckedFlag.InCheckeded,ParameterDirection.Input), new OracleParameter(":InCheckedID",OracleDbType.Int32, InCheckedID,ParameterDirection.Input), new OracleParameter(":BarCode",OracleDbType.NVarchar2, BarCode,ParameterDirection.Input), new OracleParameter(":whereInCheckedFlag",OracleDbType.Int32, Constant.InCheckedFlag.InCheckedNo,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), }; returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras); returnRows = 1;//防止多次盘点此条码,下面在回滚回来,代码是有作用 } if (returnRows == 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Disconnect(); } } return returnRows; } /// /// 停用盘点单 /// /// 盘点单号 /// public static int DisableInChecked(int InCheckedID, SUserInfo sUserInfo) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { string sql = "update TP_PM_InChecked set valueflag='0', updateuserid=:updateuserid where InCheckedID=:InCheckedID and valueflag='1'"; OracleParameter[] Paras = new OracleParameter[] { new OracleParameter(":InCheckedID",OracleDbType.Int32, InCheckedID,ParameterDirection.Input), new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input) }; returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras); if (returnRows == 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } return returnRows; } /// /// 撤销包装 /// /// 产品条码 /// public static ServiceResultEntity AddChancelFinishedproduct(string barcode, SUserInfo sUserInfo) { ServiceResultEntity entity = new ServiceResultEntity(); int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { // 转换注浆条码 barcode = CommonModuleLogic.CommonModuleLogic.GetBarcode(oracleTrConn, barcode, sUserInfo); DateTime? createTime = null; // 1 条码是否在产成品表中 string sql = "select createTime,FHUserCode,GoodsCode from tp_pm_finishedproduct where barcode=:barcode and valueflag=1"; OracleParameter[] Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds.Tables[0].Rows.Count == 0) { //不存在产成品 returnRows = -1; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } else { //wangx 2017-02-10 已经交接不允许撤销 if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["FHUserCode"].ToString())) { entity.Result = -200; //已交接,不能再次进行交接 entity.Message = "此产品【" + ds.Tables[0].Rows[0]["GoodsCode"].ToString() + "】已交接,不能进行该操作"; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); return entity; } //wangx 2017-02-10 end createTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["createTime"]); // 成品时间 } #region 是否启用成品撤销限制天数 if (createTime != null) { sql = "select settingvalue from TP_MST_SystemSetting where settingcode=:settingcode and accountid=:accountid"; Paras = new OracleParameter[] { new OracleParameter(":settingcode",OracleDbType.Varchar2, Constant.SettingType.S_PM_005.ToString(),ParameterDirection.Input), new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input) }; ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds != null && ds.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]) > 0) { // 开启了限制 ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel(Convert.ToDateTime(createTime), Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]), Constant.SettingType.S_PM_005.ToString(), sUserInfo); if (Convert.ToInt32(resultEntity.Result) < 0) { //超过成品撤销限制天数 returnRows = -200; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; entity.Message = resultEntity.Message; return entity; } } } } #endregion sql = "select 1 from tp_pm_productiondatain where barcode=:barcode and valueflag=1"; Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds.Tables[0].Rows.Count == 0) { // 2 生产数据恢复到在产生产数据 sql = @"insert into tp_pm_productiondatain ( ProductionDataID, BarCode, CentralizedBatchNo, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureID, ProcedureCode, ProcedureName, ProcedureModel, ModelType, PieceType, IsReworked, NodeType, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, SpecialRepairFlag, OrganizationID, GoodsID, GoodsCode, GoodsName, UserID, UserCode, UserName, ClassesSettingID, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, ReworkProcedureID, ReworkProcedureCode, ReworkProcedureName, GroutingDailyID, GroutingDailyDetailID, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingDate, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, AccountDate, SettlementFlag, AccountID, ValueFlag, CreateTime, CreateUserID, UpdateTime, UpdateUserID, OPTimeStamp, TriggerFlag, LogoID, BackOutTime,BackOutUserID,BackOutUserCode,CheckTime ) select ProductionDataID, BarCode, CentralizedBatchNo, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureID, ProcedureCode, ProcedureName, ProcedureModel, ModelType, PieceType, IsReworked, NodeType, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, SpecialRepairFlag, OrganizationID, GoodsID, GoodsCode, GoodsName, UserID, UserCode, UserName, ClassesSettingID, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, ReworkProcedureID, ReworkProcedureCode, ReworkProcedureName, GroutingDailyID, GroutingDailyDetailID, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingDate, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, AccountDate, SettlementFlag, AccountID, ValueFlag, CreateTime, CreateUserID, UpdateTime, UpdateUserID, OPTimeStamp, 1, LogoID, BackOutTime,BackOutUserID,BackOutUserCode,CheckTime from TP_PM_ProductionData where valueflag=1 and barcode=:barcode "; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); } // 3 停用在产生产数据包装数据 sql = "update TP_PM_ProductionDataIn set valueflag=0,updateuserID=" + sUserInfo.UserID + " where ProductionDataID=(select max(ProductionDataID) from TP_PM_ProductionDataIn where barcode=:barcode and valueflag=1)"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); // 4 插入在产数据 sql = @"insert into TP_PM_InProduction ( BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, FlowProcedureID, FlowProcedureTime, ProcedureID, ProcedureTime, ProductionDataID, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, SpecialRepairFlag, GoodsLevelID, GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, CreateTime, CreateUserID, UpdateTime, UpdateUserID, OPTimeStamp, LogoID ) select BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureID, CreateTime, ProcedureID, CreateTime, ProductionDataID, ProcedureModel, ModelType, 0, ReworkProcedureID, IsPublicBody, IsReFire, SpecialRepairFlag, GoodsLevelID, GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, CreateTime, CreateUserID, UpdateTime, UpdateUserID, OPTimeStamp, LogoID from TP_PM_ProductionData where TP_PM_ProductionData.ProductionDataID=(select max(ProductionDataID) from TP_PM_ProductionData where barcode=:barcode and valueflag=1)"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); // 5 删除产成品表 sql = "delete from tp_pm_finishedproduct where barcode=:barcode and valueflag=1"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); if (returnRows <= 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } entity.Result = returnRows; return entity; } /// /// 公坯设定 /// /// 产品条码 /// public static int AddPublicBodyProduct(string barcode, SUserInfo sUserInfo) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { // 1 条码是否在在产表中 string sql = "select ispublicbody from tp_pm_inproduction where barcode=:barcode and valueflag=1"; OracleParameter[] Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds.Tables[0].Rows.Count == 0) { //不存在生产线上, returnRows = -1; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); return returnRows; } else { if (ds.Tables[0].Rows[0]["ispublicbody"].ToString() == "1") { returnRows = -2; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); return returnRows; } } // 2 TP_PM_GroutingDailyDetail 在产盘点明细 sql = "update TP_PM_GroutingDailyDetail set ispublicbody=1 where barcode=:barcode"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); // 3 TP_PM_InCheckedDetail sql = "update TP_PM_InCheckedDetail set ispublicbody=1 where barcode=:barcode"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); // 4 TP_PM_InProduction sql = "update TP_PM_InProduction set ispublicbody=1 where barcode=:barcode"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); // 5 TP_PM_InProductionTrash sql = "update TP_PM_InProductionTrash set ispublicbody=1 where barcode=:barcode"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); // 6 TP_PM_ProductionDataIn sql = "update TP_PM_ProductionDataIn set ispublicbody=1 where barcode=:barcode"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); // 7 TP_PM_ScrapProduct sql = "update TP_PM_ScrapProduct set ispublicbody=1 where barcode=:barcode"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); if (returnRows <= 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } return returnRows; } /// /// 交坯保存校验 /// /// 连接对象 /// 工序ID /// 条码 /// 返回的产品ID /// 返回的产品Code /// 返回的产品名称 /// 返回的注浆者ID /// string /// /// 陈冰 2014.09.18 新建 /// private static string CheckBarcodeDeliverMud(IDBTransaction oracleTrConn, int procedureID, string barcode, out int goodsID, out string goodsCode, out string goodsName, out string groutingUserCode, SUserInfo sUserInfo, ref int? GroutingDailyDetailID ) { try { string sql = "select barcodestatus,barcode,GroutingDailyDetailid from TP_PM_USEDBARCODE where barcode=:barcode"; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter("barcode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input), }; DataSet ds = oracleTrConn.GetSqlResultToDs(sql, paras); string ErrorMessage = ""; if (ds != null && ds.Tables[0].Rows.Count == 0) { ErrorMessage = "无效条码"; } else { //不等于空的时候 if (ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "-1") { sql = "select max(newbarcode) from TP_PM_BarCodeRecord where BarCode='" + ds.Tables[0].Rows[0]["barcode"].ToString() + "'"; string newbarcode = oracleTrConn.GetSqlResultToStr(sql); ErrorMessage = "条码已被替换,新条码为" + newbarcode; } else if (ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "2") { ErrorMessage = "产品开模时已损坏"; } else if (ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "3") { ErrorMessage = "产品已交坯"; } } string sqlString = @"select GroutingDailyDetailid, GoodsID, GoodsCode, GoodsName, UserCode as GroutingUserCode, groutingcount as GroutingNum, GroutingMouldCode as MouldCode, ispublicbody, Groutingdate, SpecialRepairFlag from tp_pm_GroutingDailyDetail where tp_pm_GroutingDailyDetail.groutingdailydetailid=:groutingdailydetailid"; paras = new OracleParameter[]{ new OracleParameter(":groutingdailydetailid",ds.Tables[0].Rows[0]["GroutingDailyDetailid"].ToString()), }; ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); goodsID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsID"]); goodsCode = ds.Tables[0].Rows[0]["GoodsCode"].ToString(); goodsName = ds.Tables[0].Rows[0]["GoodsName"].ToString(); groutingUserCode = ds.Tables[0].Rows[0]["GroutingUserCode"].ToString(); GroutingDailyDetailID = Convert.ToInt32(ds.Tables[0].Rows[0]["GroutingDailyDetailID"]); string sqlExistGoods = "select count(GoodsID) from TP_PC_ProcedureGoods where GoodsID=:GoodsID and ProcedureID=:ProcedureID"; paras = new OracleParameter[]{ new OracleParameter(":GoodsID",ds.Tables[0].Rows[0]["GoodsID"].ToString()), new OracleParameter(":ProcedureID",procedureID), }; DataSet dsGoods = oracleTrConn.GetSqlResultToDs(sqlExistGoods, paras); if (dsGoods.Tables[0].Rows[0][0].ToString() != "1") { ErrorMessage = @"条码[" + barcode + "]不可以经过该工序\n\r原因:条码对应的产品编码[" + ds.Tables[0].Rows[0]["GoodsCode"].ToString() + "]没有在该工序中配置"; } return ErrorMessage; } catch (Exception ex) { throw ex; } } /// /// 标准计件(单点采集) /// /// 数据连接对象 /// 工序对象 /// 条码信息 /// 用户基本信息 /// 返回的产品ID /// 返回的产品Code /// 返回的产品名称 /// 返回的注浆者ID /// string /// /// 陈冰 2014.09.18 新建 /// private static string AddNormalWorkPiece2(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo, out int goodsID, out string goodsCode, out string goodsName, out string groutingUserCode) { try { goodsID = Constant.INT_IS_ZERO; goodsCode = null; goodsName = null; groutingUserCode = string.Empty; //Constant.INT_IS_ZERO; // 获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); string errMsg = string.Empty; // 本批采集的批次号 string centralizedBatchNo = System.Guid.NewGuid().ToString(); string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo; // 条码信息 foreach (DataRow barcodeRow in barcodeTable.Rows) { // 条码 string barcode = barcodeRow["Barcode"].ToString(); if (string.IsNullOrEmpty(barcode)) { throw new Exception("传入的条码号为空"); } // 生产工号 int workUserID = Convert.ToInt32(barcodeRow["UserID"]); // 生产工号 string workUserCode = barcodeRow["UserCode"].ToString(); //生产数据ID string sql = "select SEQ_PM_ProductionData_ID.nextval from dual"; int productionDataID = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sql)); int? GroutingDailyDetailID = null;//注浆明细ID if (procedure.CollectType == 1) { if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的 { #region 校验条码有效性 errMsg = CheckBarcodeDeliverMud(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo, ref GroutingDailyDetailID); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } else { #region 校验条码有效性 errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } } else { // string sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid, // tp_pm_groutingdailydetail.goodscode, // tp_pm_groutingdailydetail.goodsname, // tp_pm_groutingdailydetail.usercode as groutingUserCode // from tp_pm_groutingdailydetail where barcode=:barcode // "; string sqlGroutingInfo = ""; // sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid, // tp_pm_groutingdailydetail.goodscode, // tp_pm_groutingdailydetail.goodsname, // tp_pm_groutingdailydetail.usercode as groutingUserCode // from tp_pm_groutingdailydetail where barcode=:barcode // "; //if (procedure.NodeType == (int)Constant.ProcedureNodeType.End) //{ sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid, tp_pm_groutingdailydetail.goodscode, tp_pm_groutingdailydetail.goodsname, tp_pm_groutingdailydetail.usercode as groutingUserCode from tp_pm_groutingdailydetail where groutingdailydetailid in (select groutingdailydetailid from TP_PM_USEDBARCODE where barcode=:barcode) "; //} OracleParameter[] ReFireparas = new OracleParameter[] { new OracleParameter(":barcode",barcode), }; DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, ReFireparas); if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0) { goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]); goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString(); goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString(); groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString(); } } int? ClassesSettingID = null;//班次配置ID #region 添加生产者数据 if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的 { string GroutingUserCode = barcodeRow["GroutingUserCode"].ToString(); if (GroutingUserCode.ToLower() == workUserCode.ToLower()) { //errMsg = AddProducerDeliverAdobe(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo); } else { errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID); } } else { errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID); } if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 添加生产数据 ProductionDataEntity productionData = new ProductionDataEntity(); #region 属性赋值 productionData.GroutingDailyDetailID = GroutingDailyDetailID;//只有交坯的时候用到 productionData.ClassesSettingID = ClassesSettingID; productionData.ProductionDataID = productionDataID; productionData.Barcode = barcode; productionData.CentralizedBatchNo = centralizedBatchNo; productionData.ProductionLineID = procedure.ProductionLineID; productionData.ProductionLineCode = procedure.ProductionlineCode; productionData.ProductionLineName = procedure.ProductionlineName; productionData.CompleteProcedureID = procedure.ProcedureID; productionData.ProcedureCode = procedure.ProcedureCode; productionData.ProcedureName = procedure.ProcedureName; productionData.ProcedureModel = procedure.ProcedureModel; productionData.ModelType = procedure.ModelType; productionData.NodeType = procedure.NodeType; productionData.PieceType = procedure.PieceType; if (procedure.IsSpecialRework == 0) { productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects; //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态 //string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')"; if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)//是交坯节点,肯定不会是重烧 { productionData.IsReFire = (int)Constant.ReFireFlag.No; productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects; } ////// else ////// { ////// string sqlReFire = @"select ////// isrefire ////// from tp_pm_inproduction where barcode=:barcode ////// "; ////// OracleParameter[] ReFireparas = new OracleParameter[] { ////// new OracleParameter(":barcode",barcode), ////// }; ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas); ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0) ////// { ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0) ////// { ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]); ////// //if (productionData.IsReFire == 6) wangxin modify 20150422 因为已经大于0,定是重烧,即有缺陷 ////// //{ ////// productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect; ////// //} ////// } ////// } ////// } } else { productionData.IsReFire = (int)Constant.GoodsLevelType.ReFire; productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect; } productionData.ReworkProcedureID = null; #region 交坯判断 // 交坯节点 if (barcodeTable.Columns.Contains("IsPublicBody")) { productionData.IsPublicBody = Convert.ToInt32(barcodeRow["IsPublicBody"]); } // 非交坯节点 else { // 正常坯 productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode); } #endregion productionData.OrganizationID = procedure.OrganizationID; productionData.GoodsID = goodsID; productionData.GoodsCode = goodsCode; productionData.GoodsName = goodsName; productionData.UserID = workUserID; productionData.UserCode = barcodeRow["UserCode"].ToString(); productionData.UserName = barcodeRow["UserName"].ToString(); #endregion string OutSpecialRepairflag = "0";//干补标识 DataSet outDataSet = null; if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { errMsg = AddProductionDataDeliverMud(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, out outDataSet); } else { errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); } if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 开始节点 if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { #region 添加在产产品数据 InProductionEntity addInProductionEntity = new InProductionEntity(); addInProductionEntity.BarCode = barcode; //流程工序ID addInProductionEntity.FlowProcedureID = procedure.ProcedureID; // 当前工序 addInProductionEntity.ProcedureID = procedure.ProcedureID; //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID; // 工序模型 addInProductionEntity.ProcedureModel = procedure.ProcedureModel; // 工序类别 addInProductionEntity.ModelType = procedure.ModelType; addInProductionEntity.SpecialRepairflag = Convert.ToInt32(OutSpecialRepairflag);//干补标识 addInProductionEntity.ProductionDataID = productionDataID; #region 交坯判断 addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯 #endregion // 生产工号 addInProductionEntity.UserID = workUserID; // 执行添加 errMsg = AddInProduction(oracleTrConn, addInProductionEntity, sUserInfo, outDataSet); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion #region 中间节点 else if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle) { #region 修改在产产品数据的当前工序,清空返工工序字段 InProductionEntity addInProductionEntity = new InProductionEntity(); addInProductionEntity.BarCode = barcode; //流程工序ID addInProductionEntity.FlowProcedureID = procedure.ProcedureID; // 当前工序 addInProductionEntity.ProcedureID = procedure.ProcedureID; //当前生产数据ID addInProductionEntity.ProductionDataID = productionDataID; // 工序模型 addInProductionEntity.ProcedureModel = procedure.ProcedureModel; // 工序类别 addInProductionEntity.ModelType = procedure.ModelType; // 生产工号 addInProductionEntity.UserID = workUserID; // 缺陷标识 // addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No; //addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefect; if (procedure.IsSpecialRework == 0) { addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects; } else { addInProductionEntity.IsReFire = (int)Constant.GoodsLevelType.ReFire; addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects; } #region 交坯判断 addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯 #endregion // 执行修改 errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion #region 结束节点 else { #region 添加成品数据 删除在产产品数据 FinishedProductEntity finishedProduct = new FinishedProductEntity(); finishedProduct.BarCode = barcode; errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } InProductionEntity delInProductionEntity = new InProductionEntity(); delInProductionEntity.BarCode = barcode; // 执行删除 在产数据 errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion } return errMsg; } catch (Exception ex) { throw ex; } } /// /// 标准计件 /// /// 数据连接对象 /// 工序对象 /// 条码信息 /// 用户基本信息 /// 返回的产品ID /// 返回的产品Code /// 返回的产品名称 /// 返回的注浆者ID /// string /// /// 陈冰 2014.09.18 新建 /// private static string AddNormalWorkPieceSinglePoint(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo, int goodsID, string goodsCode, string goodsName, string groutingUserCode, int? arvGroutingDailyDetailID) { try { //goodsID = Constant.INT_IS_ZERO; //goodsCode = null; //goodsName = null; //groutingUserCode = string.Empty; //Constant.INT_IS_ZERO; // 获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); string errMsg = string.Empty; // 本批采集的批次号 string centralizedBatchNo = System.Guid.NewGuid().ToString(); string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo; // 条码信息 foreach (DataRow barcodeRow in barcodeTable.Rows) { // 条码 string barcode = barcodeRow["Barcode"].ToString(); if (string.IsNullOrEmpty(barcode)) { throw new Exception("传入的条码号为空"); } // 生产工号 int workUserID = Convert.ToInt32(barcodeRow["UserID"]); // 生产工号 string workUserCode = barcodeRow["UserCode"].ToString(); //生产数据ID string sql = "select SEQ_PM_ProductionData_ID.nextval from dual"; int productionDataID = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sql)); int? GroutingDailyDetailID = arvGroutingDailyDetailID;//注浆明细ID if (procedure.CollectType == 1) { if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的 { #region 校验条码有效性 errMsg = CheckBarcodeDeliverMud(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo, ref GroutingDailyDetailID); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } else { #region 校验条码有效性 errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } } else { // string sqlGroutingInfo = ""; // sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid, // tp_pm_groutingdailydetail.goodscode, // tp_pm_groutingdailydetail.goodsname, // tp_pm_groutingdailydetail.usercode as groutingUserCode, // tp_pm_groutingdailydetail.GroutingDailyDetailID // from tp_pm_groutingdailydetail where groutingdailydetailid in // (select groutingdailydetailid from TP_PM_USEDBARCODE where barcode=:barcode) // "; // OracleParameter[] ReFireparas = new OracleParameter[] { // new OracleParameter(":barcode",barcode), // }; // DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, ReFireparas); // if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0) // { // GroutingDailyDetailID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["GroutingDailyDetailID"]); // goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]); // goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString(); // goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString(); // groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString(); // } } int? ClassesSettingID = null;//班次配置ID #region 添加生产者数据 if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的 { string GroutingUserCode = barcodeRow["GroutingUserCode"].ToString(); if (GroutingUserCode.ToLower() == workUserCode.ToLower()) { //errMsg = AddProducerDeliverAdobe(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo); } else { errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID); } } else { errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID); } if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 添加生产数据 ProductionDataEntity productionData = new ProductionDataEntity(); if (barcodeTable.Columns.Contains("Remarks")) { productionData.Remarks = barcodeRow["Remarks"] + ""; } #region 属性赋值 productionData.GroutingDailyDetailID = GroutingDailyDetailID;//只有交坯的时候用到 productionData.ClassesSettingID = ClassesSettingID; productionData.ProductionDataID = productionDataID; productionData.Barcode = barcode; productionData.CentralizedBatchNo = centralizedBatchNo; productionData.ProductionLineID = procedure.ProductionLineID; productionData.ProductionLineCode = procedure.ProductionlineCode; productionData.ProductionLineName = procedure.ProductionlineName; productionData.CompleteProcedureID = procedure.ProcedureID; productionData.ProcedureCode = procedure.ProcedureCode; productionData.ProcedureName = procedure.ProcedureName; productionData.ProcedureModel = procedure.ProcedureModel; productionData.ModelType = procedure.ModelType; productionData.NodeType = procedure.NodeType; productionData.PieceType = procedure.PieceType; if (barcodeRow["LogoID"].ToString() != "") { productionData.LogoID = Convert.ToInt32(barcodeRow["LogoID"]); } if (procedure.IsSpecialRework == 0) { productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects; //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态 //string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')"; if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)//是交坯节点,肯定不会是重烧 { productionData.IsReFire = (int)Constant.ReFireFlag.No; productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects; } ////// else ////// { ////// string sqlReFire = @"select ////// isrefire ////// from tp_pm_inproduction where barcode=:barcode ////// "; ////// OracleParameter[] ReFireparas = new OracleParameter[] { ////// new OracleParameter(":barcode",barcode), ////// }; ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas); ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0) ////// { ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0) ////// { ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]); ////// //if (productionData.IsReFire == 6) wangxin modify 20150422 因为已经大于0,定是重烧,即有缺陷 ////// //{ ////// productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect; ////// //} ////// } ////// } ////// } } else { productionData.IsReFire = (int)Constant.GoodsLevelType.ReFire; productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect; } productionData.ReworkProcedureID = null; #region 交坯判断 // 交坯节点 if (barcodeTable.Columns.Contains("IsPublicBody")) { productionData.IsPublicBody = Convert.ToInt32(barcodeRow["IsPublicBody"]); } // 非交坯节点 else { // 正常坯 productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode); } #endregion productionData.OrganizationID = procedure.OrganizationID; productionData.GoodsID = goodsID; productionData.GoodsCode = goodsCode; productionData.GoodsName = goodsName; productionData.UserID = workUserID; productionData.UserCode = barcodeRow["UserCode"].ToString(); productionData.UserName = barcodeRow["UserName"].ToString(); #endregion string OutSpecialRepairflag = "0";//干补标识 DataSet outDataSet = null; if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { errMsg = AddProductionDataDeliverMud(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, out outDataSet); } else { errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); } if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 开始节点 if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { #region 添加在产产品数据 InProductionEntity addInProductionEntity = new InProductionEntity(); addInProductionEntity.BarCode = barcode; //流程工序ID addInProductionEntity.FlowProcedureID = procedure.ProcedureID; // 当前工序 addInProductionEntity.ProcedureID = procedure.ProcedureID; //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID; // 工序模型 addInProductionEntity.ProcedureModel = procedure.ProcedureModel; // 工序类别 addInProductionEntity.ModelType = procedure.ModelType; addInProductionEntity.SpecialRepairflag = Convert.ToInt32(OutSpecialRepairflag);//干补标识 addInProductionEntity.ProductionDataID = productionDataID; #region 交坯判断 addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯 #endregion // 生产工号 addInProductionEntity.UserID = workUserID; // 执行添加 errMsg = AddInProduction(oracleTrConn, addInProductionEntity, sUserInfo, outDataSet); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion #region 中间节点 else if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle) { #region 修改在产产品数据的当前工序,清空返工工序字段 InProductionEntity addInProductionEntity = new InProductionEntity(); addInProductionEntity.BarCode = barcode; //流程工序ID addInProductionEntity.FlowProcedureID = procedure.ProcedureID; // 当前工序 addInProductionEntity.ProcedureID = procedure.ProcedureID; //当前生产数据ID addInProductionEntity.ProductionDataID = productionDataID; // 工序模型 addInProductionEntity.ProcedureModel = procedure.ProcedureModel; // 工序类别 addInProductionEntity.ModelType = procedure.ModelType; // 生产工号 addInProductionEntity.UserID = workUserID; // 缺陷标识 // addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No; //addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefect; if (procedure.IsSpecialRework == 0) { addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects; } else { addInProductionEntity.IsReFire = (int)Constant.GoodsLevelType.ReFire; addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects; } addInProductionEntity.LogoID = productionData.LogoID == 0 ? null : productionData.LogoID; #region 交坯判断 addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯 #endregion // 执行修改 errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion #region 结束节点 else { #region 添加成品数据 删除在产产品数据 FinishedProductEntity finishedProduct = new FinishedProductEntity(); finishedProduct.BarCode = barcode; finishedProduct.LogoID = productionData.LogoID; errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } InProductionEntity delInProductionEntity = new InProductionEntity(); delInProductionEntity.BarCode = barcode; // 执行删除 在产数据 errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion } return errMsg; } catch (Exception ex) { throw ex; } } /// /// 清除在产残留数据(清除选择) /// /// 产品条码集 /// public static int SaveClearInproduction(string barcodes, SUserInfo sUserInfo) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { string sql = ""; string[] subbarcode = barcodes.Split(','); OracleParameter[] Paras = null; for (int i = 0; i < subbarcode.Length; i++) { // 0.登窑、入窑、出窑工序的产品不能清除 sql = "select p.modeltype from tp_pm_inproduction p where p.barcode = :barcode"; Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.NVarchar2, subbarcode[i],ParameterDirection.Input) }; string modeltype = oracleTrConn.GetSqlResultToStr(sql, Paras); if (!string.IsNullOrWhiteSpace(modeltype)) { Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType pmt = (Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType)Convert.ToInt32(modeltype); if (pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.LoadCar || pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.IntoKiln || pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.OutKiln) { continue; } } // 返工标识或者是报损标识不允许清除 2016-07-12 sql = "select IsReworkFlag,InScrapFlag from tp_pm_inproduction p where p.barcode = :barcode"; Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.NVarchar2, subbarcode[i],ParameterDirection.Input) }; DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds != null && ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1") { returnRows = -1; break; } if (ds.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1") { returnRows = -2; break; } } // 返工标识或者是报损标识不允许清除 end //把在产数据插入到在产临时表中。(数据来源标识0:在产表) sql = @"insert into tp_pm_inproduction_tmp ( BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION, SPECIALREPAIRFLAG, FLOWPROCEDUREID, FLOWPROCEDURETIME, PROCEDUREID, PROCEDURETIME, PRODUCTIONDATAID, trashflag, Deletedtime, logoid, IsReworkFlag, SemiCheckID, DELETEDUSERID, DELETEDUSERCODE ) select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION, SPECIALREPAIRFLAG, FLOWPROCEDUREID, FLOWPROCEDURETIME, PROCEDUREID, PROCEDURETIME, PRODUCTIONDATAID, INSCRAPFLAG, sysdate, logoid, IsReworkFlag, SemiCheckID, " + sUserInfo.UserID + ",'" + sUserInfo.UserCode + "' from tp_pm_inproduction p where p.barcode = :barcode"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); //删除在产数据 sql = "delete from tp_pm_inproduction p where p.barcode =:barcode"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); //删除在产生产数据 sql = "delete from tp_pm_productiondatain p where p.barcode =:barcode"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); } if (returnRows <= 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } return returnRows; } #region 清除在产残留数据(批量) /// /// 清除在产残留数据(批量清除) /// /// 产品条码集 /// public static int SaveClearAllInproduction(SUserInfo user, RPT010401_SE se) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { List parameters = new List(); StringBuilder sql = new StringBuilder(GetClearInproductionData(user.AccountID)); if (se != null) { //生产线IDS if (!string.IsNullOrEmpty(se.ProductionLineIDS)) { sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_InProduction.ProductionLineID||',')>0 "); parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input)); } //完成工序IDS if (!string.IsNullOrEmpty(se.ProcedureIDS)) { sql.Append(" AND instr(','||:ProcedureIDS||',',','||TP_PM_InProduction.ProcedureID||',')>0 "); parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input)); } // 生产时间--开始 if (se.UpdateTimeStart.HasValue) { sql.Append(" AND TP_PM_InProduction.Proceduretime >= :UpdateTimeStart "); parameters.Add(new OracleParameter(":UpdateTimeStart", OracleDbType.Date, se.UpdateTimeStart.Value, ParameterDirection.Input)); } // 生产时间--结束 if (se.UpdateTimeEnd.HasValue) { sql.Append(" AND TP_PM_InProduction.Proceduretime <= :UpdateTimeEnd "); parameters.Add(new OracleParameter(":UpdateTimeEnd", OracleDbType.Date, se.UpdateTimeEnd.Value, ParameterDirection.Input)); } // 是否清除报损待审产品 if (se.inscrapflag == 0) { sql.Append(" AND TP_PM_InProduction.inscrapflag=0 "); } else { sql.Append(" AND TP_PM_InProduction.inscrapflag in (0,1) "); } // 是否清除返工产品 if (se.IsReworkFlag == 0) { sql.Append(" AND TP_PM_InProduction.IsReworkFlag=0 "); } else { sql.Append(" AND TP_PM_InProduction.IsReworkFlag in (0,1) "); } } //把在产数据插入到在产临时表中。(数据来源标识0:在产表) string updatsql1 = @"insert into tp_pm_inproduction_tmp ( BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION, SPECIALREPAIRFLAG, FLOWPROCEDUREID, FLOWPROCEDURETIME, PROCEDUREID, PROCEDURETIME, PRODUCTIONDATAID, trashflag, Deletedtime, logoid, IsReworkFlag, SemiCheckID, DELETEDUSERID, DELETEDUSERCODE ) select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION, SPECIALREPAIRFLAG, FLOWPROCEDUREID, FLOWPROCEDURETIME, PROCEDUREID, PROCEDURETIME, PRODUCTIONDATAID, INSCRAPFLAG, sysdate, logoid, IsReworkFlag, SemiCheckID," + user.UserID + ",'" + user.UserCode + "' from tp_pm_inproduction p where p.barcode in (" + sql.ToString() + ")"; returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray()); //删除在产数据 updatsql1 = "delete from tp_pm_inproduction p where p.barcode in (" + sql.ToString() + ")"; returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray()); //删除在产生产数据 updatsql1 = "delete from tp_pm_productiondatain p where p.barcode in (" + sql.ToString() + ")"; returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray()); if (returnRows == 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } return returnRows; } /// /// 获取批量数据 /// /// private static string GetClearInproductionData(int accountid) { string selSql = "SELECT " + " TP_PM_InProduction.BarCode " + " FROM TP_PM_InProduction " + " Where TP_PM_InProduction.ValueFlag = '1' " + " and TP_PM_InProduction.modeltype not in (1,2,3)" + " and TP_PM_InProduction.AccountID= " + accountid; return selSql; } #endregion #region /// /// 清除在产加收站残留数据(清除选择) /// /// 产品条码集 /// public static int SaveClearInproductionTrash(string barcodes, SUserInfo user) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { string sql = ""; string[] subbarcode = barcodes.Split(','); OracleParameter[] Paras = null; for (int i = 0; i < subbarcode.Length; i++) { Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.NVarchar2, subbarcode[i],ParameterDirection.Input) }; //把在产数据插入到在产临时表中。(数据来源标识0:在产表) sql = @"insert into tp_pm_inproduction_tmp ( BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION, SPECIALREPAIRFLAG, FLOWPROCEDUREID, FLOWPROCEDURETIME, PROCEDUREID, PROCEDURETIME, PRODUCTIONDATAID, trashflag, Deletedtime, logoid, IsReworkFlag, SemiCheckID, DELETEDUSERID, DELETEDUSERCODE ) select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,1,sysdate,logoid,IsReworkFlag,SemiCheckID," + user.UserID + ",'" + user.UserCode + "' from TP_PM_InProductionTrash p where p.barcode = :barcode"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); //删除在产回收站数据 sql = "delete from TP_PM_InProductionTrash p where p.barcode =:barcode"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); //删除在产生产数据 sql = "delete from tp_pm_productiondatain p where p.barcode =:barcode"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); } if (returnRows == 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } return returnRows; } #endregion #region 清除在产回收站残留数据(批量) /// /// 清除在产残留数据(批量清除) /// /// 产品条码集 /// public static int SaveClearAllInproductionTrash(SUserInfo user, FPM2110_SE se) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { List parameters = new List(); StringBuilder sql = new StringBuilder(GetClearInproductionTrashData(user.AccountID)); if (se != null) { //生产线IDS if (!string.IsNullOrEmpty(se.ProductionLineIDS)) { sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_InProductionTrash.ProductionLineID||',')>0 "); parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input)); } //完成工序IDS if (!string.IsNullOrEmpty(se.ProcedureIDS)) { sql.Append(" AND instr(','||:ProcedureIDS||',',','||TP_PM_InProductionTrash.ProcedureID||',')>0 "); parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input)); } // 生产时间--开始 if (se.UpdateTimeStart.HasValue) { sql.Append(" AND TP_PM_InProductionTrash.Proceduretime >= :UpdateTimeStart "); parameters.Add(new OracleParameter(":UpdateTimeStart", OracleDbType.Date, se.UpdateTimeStart.Value, ParameterDirection.Input)); } // 生产时间--结束 if (se.UpdateTimeEnd.HasValue) { sql.Append(" AND TP_PM_InProductionTrash.Proceduretime <= :UpdateTimeEnd "); parameters.Add(new OracleParameter(":UpdateTimeEnd", OracleDbType.Date, se.UpdateTimeEnd.Value, ParameterDirection.Input)); } //报废日期开始 if (se.ScrapDataStart.HasValue) { sql.Append(" AND TP_PM_SCRAPPRODUCT.SCRAPDATE >= trunc(:ScrapDateStart) "); parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDataStart.Value, ParameterDirection.Input)); } //报废日期结束 if (se.ScrapDataEnd.HasValue) { sql.Append(" AND TP_PM_SCRAPPRODUCT.SCRAPDATE <= trunc(:ScrapDateEnd)"); parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDataEnd.Value, ParameterDirection.Input)); } // 产品分级 sql.Append(" AND TP_PM_SCRAPPRODUCT.GOODSLEVELTYPEID = :GooddLevelTypeID "); parameters.Add(new OracleParameter(":GooddLevelTypeID", OracleDbType.Int32, se.GooddLevelTypeID, ParameterDirection.Input)); } //把在产数据插入到在产临时表中。(数据来源标识0:在产表) string updatsql1 = @"insert into tp_pm_inproduction_tmp ( BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION, SPECIALREPAIRFLAG, FLOWPROCEDUREID, FLOWPROCEDURETIME, PROCEDUREID, PROCEDURETIME, PRODUCTIONDATAID, trashflag, Deletedtime, logoid, IsReworkFlag, SemiCheckID, DELETEDUSERID, DELETEDUSERCODE ) select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,1,sysdate,logoid,IsReworkFlag,SemiCheckID," + user.UserID + ",'" + user.UserCode + "' from TP_PM_InProductionTrash p where p.barcode in (" + sql.ToString() + ")"; returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray()); //删除在产数据 updatsql1 = "delete from TP_PM_InProductionTrash p where p.barcode in (" + sql.ToString() + ")"; returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray()); //删除在产生产数据 updatsql1 = "delete from tp_pm_productiondatain p where p.barcode in (" + sql.ToString() + ")"; returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray()); if (returnRows == 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } return returnRows; } /// /// 获取批量数据 /// /// private static string GetClearInproductionTrashData(int accountid) { string selSql = "SELECT " + " TP_PM_InProductionTrash.BarCode " + " FROM TP_PM_InProductionTrash " + " left join tp_pm_scrapproduct " + " on tp_pm_scrapproduct.barcode=TP_PM_InProductionTrash.barcode " + " Where 1=1 and TP_PM_InProductionTrash.ValueFlag = 1 " + " and TP_PM_InProductionTrash.AccountID= " + accountid; return selSql; } #endregion /// /// 清除在产临时表残留数据(清除选择) /// /// 产品条码集 /// public static int SaveClearInproductionTmp(string barcodes) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { string sql = ""; string[] subbarcode = barcodes.Split(','); OracleParameter[] Paras = null; for (int i = 0; i < subbarcode.Length; i++) { Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.NVarchar2, subbarcode[i],ParameterDirection.Input) }; //删除在产临时表数据 sql = "delete from TP_PM_InProduction_Tmp p where p.barcode =:barcode"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); } if (returnRows == 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } return returnRows; } #region 清除在产回收站残留数据(批量) /// /// 清除在产残留数据(批量清除) /// /// 产品条码集 /// public static int SaveClearAllInproductionTmp(SUserInfo user, FPM2112_SE se) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { List parameters = new List(); StringBuilder sql = new StringBuilder(GetClearInproductionTmpData(user.AccountID)); if (se != null) { //生产线IDS if (!string.IsNullOrEmpty(se.ProductionLineIDS)) { sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_InProduction_Tmp.ProductionLineID||',')>0 "); parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input)); } //完成工序IDS if (!string.IsNullOrEmpty(se.ProcedureIDS)) { sql.Append(" AND instr(','||:ProcedureIDS||',',','||TP_PM_InProduction_Tmp.ProcedureID||',')>0 "); parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input)); } // 生产时间--开始 if (se.UpdateTimeStart.HasValue) { sql.Append(" AND TP_PM_InProduction_Tmp.Proceduretime >= :UpdateTimeStart "); parameters.Add(new OracleParameter(":UpdateTimeStart", OracleDbType.Date, se.UpdateTimeStart.Value, ParameterDirection.Input)); } // 生产时间--结束 if (se.UpdateTimeEnd.HasValue) { sql.Append(" AND TP_PM_InProduction_Tmp.Proceduretime <= :UpdateTimeEnd "); parameters.Add(new OracleParameter(":UpdateTimeEnd", OracleDbType.Date, se.UpdateTimeEnd.Value, ParameterDirection.Input)); } //报废日期开始 if (se.ScrapDataStart.HasValue) { sql.Append(" AND TP_PM_SCRAPPRODUCT.SCRAPDATE >= trunc(:ScrapDateStart) "); parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDataStart.Value, ParameterDirection.Input)); } //报废日期结束 if (se.ScrapDataEnd.HasValue) { sql.Append(" AND TP_PM_SCRAPPRODUCT.SCRAPDATE <= trunc(:ScrapDateEnd)"); parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDataEnd.Value, ParameterDirection.Input)); } if (se.GooddLevelTypeID != null) { // 产品分级 sql.Append(" AND TP_PM_SCRAPPRODUCT.GOODSLEVELTYPEID = :GooddLevelTypeID "); parameters.Add(new OracleParameter(":GooddLevelTypeID", OracleDbType.Int32, se.GooddLevelTypeID, ParameterDirection.Input)); } //在产or 回收站 sql.Append(" AND TP_PM_InProduction_Tmp.TrashFlag = :TrashFlag "); parameters.Add(new OracleParameter(":TrashFlag", OracleDbType.Int32, se.TrashFlag, ParameterDirection.Input)); } //删除在产临时表数据 string updatsql1 = "delete from TP_PM_InProduction_Tmp p where p.barcode in (" + sql.ToString() + ")"; returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray()); if (returnRows == 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } return returnRows; } /// /// 获取批量数据 /// /// private static string GetClearInproductionTmpData(int accountid) { string selSql = "SELECT " + " TP_PM_InProduction_Tmp.BarCode " + " FROM TP_PM_InProduction_Tmp " + " left join tp_pm_scrapproduct " + " on tp_pm_scrapproduct.barcode=TP_PM_InProduction_Tmp.barcode " + " Where 1=1 and TP_PM_InProduction_Tmp.ValueFlag = 1 " + " and TP_PM_InProduction_Tmp.AccountID= " + accountid; return selSql; } #endregion #region 恢复数据 /// /// 恢复数据 /// /// 产品条码集 /// public static int ResetBarCode(string barcode) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { string sql = "select trashflag from Tp_Pm_Inproduction_Tmp where barcode=:barcode"; OracleParameter[] Paras = Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.NVarchar2, barcode,ParameterDirection.Input) }; DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds != null && ds.Tables[0].Rows.Count == 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); return -1; //此条码没有清除,不能恢复 } if (ds.Tables[0].Rows[0]["trashflag"].ToString() == "0") //在产删除 { sql = @"insert into tp_pm_inproduction select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,0,logoid,IsReworkFlag,SemiCheckID from TP_PM_InProduction_Tmp p where p.barcode = :barcode"; } else { sql = @"insert into tp_pm_inproductiontrash select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, defectflag, REWORKPROCEDUREID, ISPUBLICBODY, ISRefire, GOODSLEVELID, GOODSLEVELTYPEID, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, REMARKS, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp, SpecialRepairFlag,FlowProcedureID ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid,IsReworkFlag,SemiCheckID from TP_PM_InProduction_Tmp p where p.barcode = :barcode"; } returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); //将生产数据表中的数据插入到在产生产数据表中 sql = @"insert into tp_pm_productiondatain select pd.PRODUCTIONDATAID, pd.BARCODE, pd.CENTRALIZEDBATCHNO, pd.PRODUCTIONLINEID, pd.PRODUCTIONLINECODE, pd.PRODUCTIONLINENAME, pd.PROCEDUREID, pd.PROCEDURECODE, pd.PROCEDURENAME, pd.PROCEDUREMODEL, pd.MODELTYPE, pd.PIECETYPE, pd.ISREWORKED, pd.NODETYPE, pd.ISPUBLICBODY, pd.ISREFIRE, pd.ORGANIZATIONID, pd.GOODSID, pd.GOODSCODE, pd.GOODSNAME, pd.USERID, pd.USERCODE, pd.USERNAME, pd.KILNID, pd.KILNCODE, pd.KILNNAME, pd.KILNCARID, pd.KILNCARCODE, pd.KILNCARNAME, pd.KILNCARBATCHNO, pd.KILNCARPOSITION, pd.REWORKPROCEDUREID, pd.REWORKPROCEDURECODE, pd.REWORKPROCEDURENAME, pd.REMARKS,pd.ACCOUNTDATE,pd.SETTLEMENTFLAG,pd.ACCOUNTID,pd.VALUEFLAG, pd.CREATETIME,pd.CREATEUSERID,pd.UPDATETIME,pd.UPDATEUSERID,pd.OPTIMESTAMP, pd.GOODSLEVELID,pd.GOODSLEVELTYPEID,pd.GROUTINGDATE,pd.GROUTINGMOULDCODE,pd.MOULDCODE, pd.GROUTINGUSERID,pd.GROUTINGUSERCODE,pd.GROUTINGNUM,pd.GROUTINGDAILYID,pd.GROUTINGDAILYDETAILID, pd.GROUTINGLINEID,pd.GROUTINGLINECODE,pd.GROUTINGLINENAME,pd.GMOULDTYPEID,pd.CANMANYTIMES, pd.GROUTINGLINEDETAILID,pd.SPECIALREPAIRFLAG,pd.CLASSESSETTINGID, '1',pd.LOGOID, pd.BackOutTime,pd.BackOutUserID,pd.BackOutUserCode,pd.checktime from tp_pm_productiondata pd where pd.barcode = :barcode and pd.productiondataid not in (select pp.productiondataid from tp_pm_productiondatain pp where pp.barcode = :barcode)"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); //删除在产临时表数据 sql = "delete from TP_PM_InProduction_Tmp p where p.barcode =:barcode"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); if (returnRows == 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } return returnRows; } /// /// 批量恢复数据 /// /// 产品条码集 /// public static int ResetSelectedBarCode(string barcodes) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { string sql = ""; string[] subbarcode = barcodes.Split(','); OracleParameter[] Paras = null; DataSet ds = null; for (int i = 0; i < subbarcode.Length; i++) { sql = "select trashflag from Tp_Pm_Inproduction_Tmp where barcode=:barcode"; Paras = Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.NVarchar2, subbarcode[i],ParameterDirection.Input) }; ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds != null && ds.Tables[0].Rows.Count == 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); return -1; //此条码没有清除,不能恢复 } if (ds.Tables[0].Rows[0]["trashflag"].ToString() == "0") //在产删除 { sql = @"insert into tp_pm_inproduction select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,0,logoid,IsReworkFlag,SemiCheckID from TP_PM_InProduction_Tmp p where p.barcode = :barcode"; } else { sql = @"insert into tp_pm_inproductiontrash select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, defectflag, REWORKPROCEDUREID, ISPUBLICBODY, ISRefire, GOODSLEVELID, GOODSLEVELTYPEID, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, REMARKS, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp, SpecialRepairFlag,FlowProcedureID ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid,IsReworkFlag,SemiCheckID from TP_PM_InProduction_Tmp p where p.barcode = :barcode"; } returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); //将生产数据表中的数据插入到在产生产数据表中 sql = @"insert into tp_pm_productiondatain select pd.PRODUCTIONDATAID, pd.BARCODE, pd.CENTRALIZEDBATCHNO, pd.PRODUCTIONLINEID, pd.PRODUCTIONLINECODE, pd.PRODUCTIONLINENAME, pd.PROCEDUREID, pd.PROCEDURECODE, pd.PROCEDURENAME, pd.PROCEDUREMODEL, pd.MODELTYPE, pd.PIECETYPE, pd.ISREWORKED, pd.NODETYPE, pd.ISPUBLICBODY, pd.ISREFIRE, pd.ORGANIZATIONID, pd.GOODSID, pd.GOODSCODE, pd.GOODSNAME, pd.USERID, pd.USERCODE, pd.USERNAME, pd.KILNID, pd.KILNCODE, pd.KILNNAME, pd.KILNCARID, pd.KILNCARCODE, pd.KILNCARNAME, pd.KILNCARBATCHNO, pd.KILNCARPOSITION, pd.REWORKPROCEDUREID, pd.REWORKPROCEDURECODE, pd.REWORKPROCEDURENAME, pd.REMARKS,pd.ACCOUNTDATE,pd.SETTLEMENTFLAG,pd.ACCOUNTID,pd.VALUEFLAG, pd.CREATETIME,pd.CREATEUSERID,pd.UPDATETIME,pd.UPDATEUSERID,pd.OPTIMESTAMP, pd.GOODSLEVELID,pd.GOODSLEVELTYPEID,pd.GROUTINGDATE,pd.GROUTINGMOULDCODE,pd.MOULDCODE, pd.GROUTINGUSERID,pd.GROUTINGUSERCODE,pd.GROUTINGNUM,pd.GROUTINGDAILYID,pd.GROUTINGDAILYDETAILID, pd.GROUTINGLINEID,pd.GROUTINGLINECODE,pd.GROUTINGLINENAME,pd.GMOULDTYPEID,pd.CANMANYTIMES, pd.GROUTINGLINEDETAILID,pd.SPECIALREPAIRFLAG,pd.CLASSESSETTINGID, '1',pd.LOGOID, pd.BackOutTime,pd.BackOutUserID,pd.BackOutUserCode,pd.checktime from tp_pm_productiondata pd where pd.barcode = :barcode and pd.productiondataid not in (select pp.productiondataid from tp_pm_productiondatain pp where pp.barcode = :barcode)"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); //删除在产临时表数据 sql = "delete from TP_PM_InProduction_Tmp p where p.barcode =:barcode"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); } if (returnRows == 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } return returnRows; } #endregion /// /// 撤销特殊工序撤销 /// /// 产品条码 /// public static ServiceResultEntity AddChancelBarCode(string barcode, SUserInfo sUserInfo) { ServiceResultEntity entity = new ServiceResultEntity(); int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { // 转换注浆条码 barcode = CommonModuleLogic.CommonModuleLogic.GetBarcode(oracleTrConn, barcode, sUserInfo); DateTime? flowProcedureTime = null; // 1 条码是否有效 string sql = "select 1 from TP_PM_GroutingDailyDetail where barcode=:barcode and valueflag=1"; OracleParameter[] Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds.Tables[0].Rows.Count == 0) { //无效条码 returnRows = -1; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } // 2.看看是否在产,如果在产看看是否已经损坯标识 int? ProcedureID = null; // 撤销时,需要判定当前工序,而不是流程工序,干补时,当前工序是干补,流程工序是报损时的工序。 //sql = "select InScrapFlag,flowProcedureID,IsReworkFlag,flowProcedureTime from TP_PM_InProduction where barcode=:barcode and valueflag=1"; sql = "select InScrapFlag,ProcedureID,IsReworkFlag,ProcedureTime from TP_PM_InProduction where barcode=:barcode and valueflag=1"; Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds.Tables[0].Rows.Count == 0) //不存在在产信息 { // 不在产,看看是否有成品 sql = @"select 1 from TP_PM_FinishedProduct where barcode=:barcode"; ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds.Tables[0].Rows.Count > 0) { //生产完成 returnRows = -2; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } else { //条码不在生产线上 returnRows = -7; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } } else { if (ds.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1") { //申请报废 returnRows = -3; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1") { //申请报废 returnRows = -9; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } //ProcedureID = Convert.ToInt32(ds.Tables[0].Rows[0]["flowProcedureID"]); //条码完成工序 //flowProcedureTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["flowProcedureTime"]); // 流程工序时间 ProcedureID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProcedureID"]); //条码完成工序 flowProcedureTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["ProcedureTime"]); // 完成工序时间 } // 此工序所在条码是否是特殊工序,即可以撤销工序 sql = "select UnDoFlag from tp_pc_procedure where procedureid=:procdureid and valueflag=1"; Paras = new OracleParameter[] { new OracleParameter(":procdureid",OracleDbType.Int32, ProcedureID,ParameterDirection.Input) }; ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds != null && ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["UnDoFlag"].ToString() != "1") { //此条码所在工序不允许进行撤销 returnRows = -4; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } } // 如果不合格,查询报损表里是否回收 sql = "select recyclingflag from TP_PM_ScrapProduct " + " where BarCode=:BarCode and CreateTime=(select max(CreateTime) " + " from TP_PM_ScrapProduct " + " where BarCode=:BarCode and ValueFlag=1)" + " and ValueFlag=1"; Paras = new OracleParameter[]{ new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input), }; DataSet dsResult2 = oracleTrConn.GetSqlResultToDs(sql, Paras); if (dsResult2 != null && dsResult2.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(dsResult2.Tables[0].Rows[0]["recyclingflag"]) > 0) { returnRows = -200; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; entity.Message = "此产品已经回收,不能撤销"; return entity; } } // 判断是否有撤销范围权限 sql = @"select 1 from TP_MST_UserPurview where UserID=:UserID and (PurviewID=:PurviewID or PurviewID=-1) and PurviewType=13"; Paras = new OracleParameter[] { new OracleParameter(":PurviewID",OracleDbType.Int32, ProcedureID,ParameterDirection.Input), new OracleParameter(":UserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input) }; ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds != null && ds.Tables[0].Rows.Count == 0) { //此条码所在工序不允许进行撤销 returnRows = -8; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } // #region 是否启用交坯撤销限制天数 if (flowProcedureTime != null) { sql = "select settingvalue from TP_MST_SystemSetting where settingcode=:settingcode and accountid=:accountid"; Paras = new OracleParameter[] { new OracleParameter(":settingcode",OracleDbType.Varchar2, Constant.SettingType.S_PM_004.ToString(),ParameterDirection.Input), new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input) }; ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds != null && ds.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]) > 0) { // 开启了限制 ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel(Convert.ToDateTime(flowProcedureTime), Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]), Constant.SettingType.S_PM_004.ToString(), sUserInfo); if (Convert.ToInt32(resultEntity.Result) < 0) { //计件撤销限制天数 returnRows = -200; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; entity.Message = resultEntity.Message; return entity; } } } } #endregion // 进行撤销 string sqlString = @"select ProductionDataID, ProcedureID, ProcedureModel, ModelType, ReworkProcedureID, UserID, logoid, (select max(ProcedureID) from Tp_Pm_ProductiondataIn inpp where inpp.barcode = :barcode and inpp.ProductionDataID > t.ProductionDataID and ModelType=8 and valueflag='1') p8id --干补 from (select ProductionDataID, ProcedureID, ProcedureModel, ModelType, ReworkProcedureID, UserID, logoid from Tp_Pm_ProductiondataIn where barcode = :barcode and valueflag = 1 and ModelType<>8 order by ProductionDataID desc) t where rownum <= 2"; Paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; DataSet productionData = oracleTrConn.GetSqlResultToDs(sqlString, Paras); if (productionData == null || productionData.Tables.Count == Constant.INT_IS_ZERO || productionData.Tables[0].Rows.Count != Constant.INT_IS_TWO) { // 条码至少要有2次数据采集 //条码没有此工序前数据 returnRows = -5; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } object pid = productionData.Tables[0].Rows[1]["p8id"]; if (pid == null || pid == DBNull.Value) { pid = productionData.Tables[0].Rows[1]["ProcedureID"]; } #region 回滚在产数据 sqlString = @"update TP_PM_InProduction set FlowProcedureID = :flowProcedureID, ProcedureModel = :procedureModel, ProcedureID = :ProcedureID, ModelType = :modelType, ReworkProcedureID = :reworkProcedureID, UserID = :userID, updateuserid = :updateuserid, ProductionDataID = :ProductionDataID --logoid = :logoid where barcode = :barcode"; Paras = new OracleParameter[]{ new OracleParameter(":flowProcedureID",OracleDbType.Int32, productionData.Tables[0].Rows[1]["ProcedureID"],ParameterDirection.Input),//1--->0 new OracleParameter(":ProcedureID",OracleDbType.Int32, pid,ParameterDirection.Input), new OracleParameter(":procedureModel",OracleDbType.Int32, productionData.Tables[0].Rows[1]["procedureModel"],ParameterDirection.Input), new OracleParameter(":modelType",OracleDbType.Int32, productionData.Tables[0].Rows[1]["modelType"],ParameterDirection.Input), new OracleParameter(":reworkProcedureID",OracleDbType.Int32, productionData.Tables[0].Rows[1]["reworkProcedureID"],ParameterDirection.Input), new OracleParameter(":userID",OracleDbType.Int32, productionData.Tables[0].Rows[1]["userID"],ParameterDirection.Input), new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), new OracleParameter(":ProductionDataID",OracleDbType.Int32, productionData.Tables[0].Rows[1]["ProductionDataID"],ParameterDirection.Input) //new OracleParameter(":logoid",OracleDbType.Int32, // productionData.Tables[0].Rows[1]["logoid"].ToString()==""?null:productionData.Tables[0].Rows[1]["logoid"],ParameterDirection.Input), }; int rutenRows = oracleTrConn.ExecuteNonQuery(sqlString, Paras); returnRows += rutenRows; if (rutenRows == Constant.INT_IS_ZERO) { // 保存失败 //没有任何影响行 returnRows = -6; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } //modify end sqlString = "update Tp_Pm_ProductiondataIn set valueflag=0 ,updateuserid=" + sUserInfo.UserID; //wangxin 20150406 //sqlString += " where ProductionDataID=:productionDataID"; //新添加的 begin Paras = new OracleParameter[]{ new OracleParameter(":productionDataID",OracleDbType.Int32, Convert.ToInt32(productionData.Tables[0].Rows[0]["productionDataID"]),ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; //新添加的 end sqlString += " where ProductionDataID=:productionDataID and barcode=:barcode"; rutenRows = oracleTrConn.ExecuteNonQuery(sqlString, Paras); returnRows += rutenRows; if (rutenRows == Constant.INT_IS_ZERO) { // 保存失败 //没有任何影响行 returnRows = -6; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } #endregion if (returnRows <= 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } entity.Result = returnRows; return entity; } /// /// 交坯特殊工序撤销 /// /// 产品条码 /// public static ServiceResultEntity AddChancelDeliverMudBarCode(string barcode, SUserInfo sUserInfo) { ServiceResultEntity entity = new ServiceResultEntity(); int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { DateTime? deliverTime = null; // 1 条码是否有效 string sql = "select DeliverTime from TP_PM_GroutingDailyDetail where barcode=:barcode and valueflag=1"; OracleParameter[] Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds.Tables[0].Rows.Count == 0) { //无效条码 returnRows = -1; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } else { if (ds.Tables[0].Rows[0]["DeliverTime"].ToString() != "") { deliverTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["DeliverTime"]); } } // 2.看看是否在产,如果在产看看是否已经损坯标识 int? ProcedureID = null; sql = "select InScrapFlag,flowProcedureID,IsReworkFlag,Specialrepairflag from TP_PM_InProduction where barcode=:barcode and valueflag=1"; Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds.Tables[0].Rows.Count == 0) //不存在在产信息 { // 不在产,看看是否有成品 sql = @"select 1 from TP_PM_FinishedProduct where barcode=:barcode"; ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds.Tables[0].Rows.Count > 0) { //生产完成 returnRows = -2; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } else { //条码不在生产线上 returnRows = -7; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } } else { if (ds.Tables[0].Rows[0]["Specialrepairflag"].ToString() == "1") { //干补后不允许撤销 returnRows = -200; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; entity.Message = "干补后不允许撤销"; return entity; } if (ds.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1") { //申请报废 returnRows = -3; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1") { //申请报废 returnRows = -8; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } ProcedureID = Convert.ToInt32(ds.Tables[0].Rows[0]["flowProcedureID"]); //条码完成工序 } //// 此工序所在条码是否是特殊工序,即可以撤销工序 //sql = "select UnDoFlag from tp_pc_procedure where procedureid=:procdureid and valueflag=1"; //Paras = new OracleParameter[] { // new OracleParameter(":procdureid",OracleDbType.Int32, // ProcedureID,ParameterDirection.Input) //}; //ds = oracleTrConn.GetSqlResultToDs(sql, Paras); //if (ds != null && ds.Tables[0].Rows.Count > 0) //{ // if (ds.Tables[0].Rows[0]["UnDoFlag"].ToString() != "1") // { // //此条码所在工序不允许进行撤销 // returnRows = -4; // oracleTrConn.Rollback(); // oracleTrConn.Disconnect(); // return returnRows; // } //} #region 是否启用交坯撤销限制天数 if (deliverTime != null) { sql = "select settingvalue from TP_MST_SystemSetting where settingcode=:settingcode and accountid=:accountid"; Paras = new OracleParameter[] { new OracleParameter(":settingcode",OracleDbType.Varchar2, Constant.SettingType.S_PM_003.ToString(),ParameterDirection.Input), new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input) }; ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds != null && ds.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]) > 0) { // 开启了限制 ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel(Convert.ToDateTime(deliverTime), Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]), Constant.SettingType.S_PM_003.ToString(), sUserInfo); if (Convert.ToInt32(resultEntity.Result) < 0) { //超过交坯撤销限制天数 returnRows = -200; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; entity.Message = resultEntity.Message; return entity; } } } } #endregion // 进行撤销 string sqlString = @"select ProductionDataID, ProcedureID, ProcedureModel, ModelType, ReworkProcedureID, UserID from (select ProductionDataID, ProcedureID, ProcedureModel, ModelType, ReworkProcedureID, UserID from Tp_Pm_ProductiondataIn where barcode = :barcode and valueflag = 1 and ModelType<>8 order by ProductionDataID desc) where rownum <= 2"; Paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; DataSet productionData = oracleTrConn.GetSqlResultToDs(sqlString, Paras); if (productionData == null || productionData.Tables.Count == Constant.INT_IS_ZERO ) { // 条码至少要有1次数据采集 //条码没有此工序前数据 returnRows = -5; //条码至少要有1次数据采集 oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } if (productionData.Tables[0].Rows.Count != Constant.INT_IS_ONE) { // 条码至少要有1次数据采集 //条码没有此工序前数据 returnRows = -55; //条码已经经过多个工序,不允许撤销 oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } #region 回滚在产数据 // sqlString = @"update TP_PM_InProduction // set FlowProcedureID = :flowProcedureID, // ProcedureModel = :procedureModel, // ProcedureID = :flowProcedureID, // ModelType = :modelType, // ReworkProcedureID = :reworkProcedureID, // UserID = :userID, // updateuserid = :updateuserid // where barcode = :barcode"; // Paras = new OracleParameter[]{ // new OracleParameter(":flowProcedureID",OracleDbType.Int32, // productionData.Tables[0].Rows[1]["ProcedureID"],ParameterDirection.Input),//1--->0 // new OracleParameter(":procedureModel",OracleDbType.Int32, // productionData.Tables[0].Rows[1]["procedureModel"],ParameterDirection.Input), // new OracleParameter(":modelType",OracleDbType.Int32, // productionData.Tables[0].Rows[1]["modelType"],ParameterDirection.Input), // new OracleParameter(":reworkProcedureID",OracleDbType.Int32, // productionData.Tables[0].Rows[1]["reworkProcedureID"],ParameterDirection.Input), // new OracleParameter(":userID",OracleDbType.Int32, // productionData.Tables[0].Rows[1]["userID"],ParameterDirection.Input), // new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), // new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), // }; // int rutenRows = oracleTrConn.ExecuteNonQuery(sqlString, Paras); // returnRows += rutenRows; // if (rutenRows == Constant.INT_IS_ZERO) // { // // 保存失败 // //没有任何影响行 // returnRows = -6; // oracleTrConn.Rollback(); // oracleTrConn.Disconnect(); // return returnRows; // } int rutenRows = 0; //modify end sqlString = "update Tp_Pm_ProductiondataIn set valueflag=0 ,updateuserid=" + sUserInfo.UserID; //wangxin 20150406 //sqlString += " where ProductionDataID=:productionDataID"; //新添加的 begin Paras = new OracleParameter[]{ new OracleParameter(":productionDataID",OracleDbType.Int32, Convert.ToInt32(productionData.Tables[0].Rows[0]["productionDataID"]),ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; //新添加的 end sqlString += " where ProductionDataID=:productionDataID and barcode=:barcode"; rutenRows = oracleTrConn.ExecuteNonQuery(sqlString, Paras); returnRows += rutenRows; if (rutenRows == Constant.INT_IS_ZERO) { // 保存失败 //没有任何影响行 returnRows = -6; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } //modify end sqlString = "delete from TP_PM_InProduction where barcode=:barcode"; //wangxin 20150406 //sqlString += " where ProductionDataID=:productionDataID"; //新添加的 begin Paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; rutenRows = oracleTrConn.ExecuteNonQuery(sqlString, Paras); returnRows += rutenRows; if (rutenRows == Constant.INT_IS_ZERO) { // 保存失败 //没有任何影响行 returnRows = -6; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; return entity; } #endregion // 更新注浆明交坯标识把已经交坯改回,正常交坯 sqlString = "update TP_PM_GroutingDailyDetail set SpecialRepairFlag=0,ScrapFlag=0,IsPublicBody=0,DeliverFlag=0,DeliverTime=null,DeliverUserID=null,DeliverUserCode=null where barcode=:barcode"; //wangxin 20150406 Paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; rutenRows = oracleTrConn.ExecuteNonQuery(sqlString, Paras); returnRows += rutenRows; sql = "update TP_PM_USEDBARCODE set barcodestatus=1 where BarCode=:barcode"; Paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; rutenRows = oracleTrConn.ExecuteNonQuery(sql, Paras); returnRows += rutenRows; if (returnRows <= 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } entity.Result = returnRows; return entity; } #region /// /// 清除未盘点残留数据(清除选择) /// /// 盘点单ID /// 条码集 /// public static int SaveClearInChecked(int inCheckedID, string barcodes, SUserInfo sUserInfo) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { string sql = ""; string[] subbarcodes = barcodes.Split(','); OracleParameter[] Paras = null; for (int i = 0; i < subbarcodes.Length; i++) { // 0.登窑、入窑、出窑工序的产品不能清除 sql = "select p.modeltype from tp_pm_inproduction p where p.barcode = :barcode"; Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.NVarchar2, subbarcodes[i],ParameterDirection.Input), }; string modeltype = oracleTrConn.GetSqlResultToStr(sql, Paras); if (!string.IsNullOrWhiteSpace(modeltype)) { Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType pmt = (Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType)Convert.ToInt32(modeltype); if (pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.LoadCar || pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.IntoKiln || pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.OutKiln || pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.CarAdd) { continue; } } // 返工标识或者是报损标识不允许清除 2016-07-12 sql = "select IsReworkFlag,InScrapFlag from tp_pm_inproduction p where p.barcode = :barcode"; Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.NVarchar2, subbarcodes[i],ParameterDirection.Input) }; DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds != null && ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1") { returnRows = -1; break; } if (ds.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1") { returnRows = -2; break; } } // 1.清除未盘点数据 sql = @"update TP_PM_INCHECKEDDETAIL p set p.INCHECKEDFLAG = '3' /*, p.valueflag='0'*/ where p.INCHECKEDID=:InCheckedID and p.barcode =:barcode and p.InCheckedFlag='0'"; Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.NVarchar2, subbarcodes[i],ParameterDirection.Input), new OracleParameter(":InCheckedID",OracleDbType.Int32, inCheckedID,ParameterDirection.Input) }; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); // 2. 把在产数据插入到在产临时表中。(数据来源标识0:在产表) // sql = @"insert into tp_pm_inproduction_tmp // select * from tp_pm_inproduction p where p.barcode = :barcode"; sql = "INSERT INTO tp_pm_inproduction_tmp\n" + " (barcode\n" + " ,productionlineid\n" + " ,productionlinecode\n" + " ,productionlinename\n" + " ,proceduremodel\n" + " ,modeltype\n" + " ,reworkprocedureid\n" + " ,ispublicbody\n" + " ,goodsid\n" + " ,goodscode\n" + " ,goodsname\n" + " ,userid\n" + " ,groutingdailyid\n" + " ,groutingdailydetailid\n" + " ,groutingdate\n" + " ,groutinglineid\n" + " ,groutinglinecode\n" + " ,groutinglinename\n" + " ,gmouldtypeid\n" + " ,canmanytimes\n" + " ,groutinglinedetailid\n" + " ,groutingmouldcode\n" + " ,mouldcode\n" + " ,remarks\n" + " ,accountid\n" + " ,valueflag\n" + " ,createtime\n" + " ,createuserid\n" + " ,updatetime\n" + " ,updateuserid\n" + " ,optimestamp\n" + " ,isrefire\n" + " ,goodslevelid\n" + " ,goodsleveltypeid\n" + " ,defectflag\n" + " ,groutinguserid\n" + " ,groutingusercode\n" + " ,groutingnum\n" + " ,kilnid\n" + " ,kilncode\n" + " ,kilnname\n" + " ,kilncarid\n" + " ,kilncarcode\n" + " ,kilncarname\n" + " ,kilncarbatchno\n" + " ,kilncarposition\n" + " ,specialrepairflag\n" + " ,flowprocedureid\n" + " ,flowproceduretime\n" + " ,procedureid\n" + " ,proceduretime\n" + " ,productiondataid\n" + " ,deleteduserid\n" + " ,deletedusercode\n" + " --,trashflag\n" + " --,deletedtime\n" + " ,logoid)\n" + " SELECT barcode\n" + " ,productionlineid\n" + " ,productionlinecode\n" + " ,productionlinename\n" + " ,proceduremodel\n" + " ,modeltype\n" + " ,reworkprocedureid\n" + " ,ispublicbody\n" + " ,goodsid\n" + " ,goodscode\n" + " ,goodsname\n" + " ,userid\n" + " ,groutingdailyid\n" + " ,groutingdailydetailid\n" + " ,groutingdate\n" + " ,groutinglineid\n" + " ,groutinglinecode\n" + " ,groutinglinename\n" + " ,gmouldtypeid\n" + " ,canmanytimes\n" + " ,groutinglinedetailid\n" + " ,groutingmouldcode\n" + " ,mouldcode\n" + " ,remarks\n" + " ,accountid\n" + " ,valueflag\n" + " ,createtime\n" + " ,createuserid\n" + " ,updatetime\n" + " ,updateuserid\n" + " ,optimestamp\n" + " ,isrefire\n" + " ,goodslevelid\n" + " ,goodsleveltypeid\n" + " ,defectflag\n" + " ,groutinguserid\n" + " ,groutingusercode\n" + " ,groutingnum\n" + " ,kilnid\n" + " ,kilncode\n" + " ,kilnname\n" + " ,kilncarid\n" + " ,kilncarcode\n" + " ,kilncarname\n" + " ,kilncarbatchno\n" + " ,kilncarposition\n" + " ,specialrepairflag\n" + " ,flowprocedureid\n" + " ,flowproceduretime\n" + " ,procedureid\n" + " ,proceduretime\n" + " ,productiondataid\n" + " ,:deleteduserid\n" + " ,:deletedusercode\n" + " --,inscrapflag\n" + " ,logoid\n" + " FROM tp_pm_inproduction p\n" + " WHERE p.barcode = :barcode\n" + " AND p.modeltype not in (1,2,3,6)\n" + " AND p.IsReworkFlag <> '1' AND p.InScrapFlag <> '1' \n" + ""; Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.NVarchar2, subbarcodes[i],ParameterDirection.Input), new OracleParameter(":deleteduserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":deletedusercode",OracleDbType.NVarchar2, sUserInfo.UserCode,ParameterDirection.Input), }; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); // 3 删除在产数据 sql = @" delete from tp_pm_inproduction p where p.barcode =:barcode AND p.modeltype not in (1,2,3,6) AND p.IsReworkFlag <> '1' AND p.InScrapFlag <> '1'"; Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.NVarchar2, subbarcodes[i],ParameterDirection.Input), }; returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras); if (returnRows > 0) { // 4. 删除在产生产数据 sql = @" delete from tp_pm_productiondatain p where p.barcode = :barcode"; Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.NVarchar2, subbarcodes[i],ParameterDirection.Input), }; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); } } if (returnRows <= 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } return returnRows; } /// /// 清除未盘点残留数据(根据条件进行选择) /// /// 盘点单ID /// 完成工序集 /// 产品编码集 /// public static int SaveClearInCheckedAll(int inCheckedID, string procedureIDs, string goodsCodes, DateTime? startDateTime, DateTime? endDateTime, SUserInfo sUserInfo) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { OracleParameter[] Paras = null; string Insql = ""; // 1 查出根据条件进行未盘点数据 // 0.登窑、入窑、出窑工序的产品不能清除 Insql = @"select p.barcode from TP_PM_INCHECKEDDETAIL p " + " inner join tp_pm_inproduction pin on pin.barcode = p.barcode and p.PROCEDUREID = pin.PROCEDUREID" + " where p.INCHECKEDID=:InCheckedID and p.InCheckedFlag in ('0','9') and (pin.modeltype is null or pin.modeltype not in (1,2,3,6)) and pin.IsReworkFlag='0' and pin.InScrapFlag='0'"; if (!string.IsNullOrEmpty(procedureIDs)) { Insql += " and p.PROCEDUREID in (" + procedureIDs + ")"; } if (!string.IsNullOrEmpty(goodsCodes)) { Insql += " and p.GoodsID in (" + goodsCodes + ")"; } if (startDateTime != null) { Insql += Insql + " AND pin.ProcedureTime >= :Createdate AND pin.ProcedureTime <= :EndDate "; Paras = new OracleParameter[] { new OracleParameter(":InCheckedID",OracleDbType.Int32,inCheckedID,ParameterDirection.Input), new OracleParameter(":Createdate", OracleDbType.Date, startDateTime, ParameterDirection.Input), new OracleParameter(":EndDate", OracleDbType.Date, endDateTime, ParameterDirection.Input), }; } else { Paras = new OracleParameter[] { new OracleParameter(":InCheckedID",OracleDbType.Int32,inCheckedID,ParameterDirection.Input), }; } string sql = ""; // 1.清除未盘点数据 sql = @"update TP_PM_INCHECKEDDETAIL p set p.INCHECKEDFLAG = '9' /*, p.valueflag='0'*/ where p.INCHECKEDID=:InCheckedID and p.barcode in (" + Insql + ") and p.InCheckedFlag='0'"; //Paras = new OracleParameter[] { // new OracleParameter(":InCheckedID",OracleDbType.Int32, // inCheckedID,ParameterDirection.Input) // }; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); // 2. 把在产数据插入到在产临时表中。(数据来源标识0:在产表) sql = @"insert into tp_pm_inproduction_tmp ( BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION, SPECIALREPAIRFLAG, FLOWPROCEDUREID, FLOWPROCEDURETIME, PROCEDUREID, PROCEDURETIME, PRODUCTIONDATAID, trashflag, Deletedtime, logoid, IsReworkFlag, SemiCheckID, DELETEDUSERID, DELETEDUSERCODE ) select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,0,sysdate,logoid,ISREWORKFLAG,SEMICHECKID," + sUserInfo.UserID + ",'" + sUserInfo.UserCode + "' from tp_pm_inproduction pp where pp.barcode in (" + Insql + ")"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); // 4. 删除在产生产数据 sql = @" delete from tp_pm_productiondatain pp where pp.barcode in(" + Insql + ")"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); // 3 删除在产数据 sql = @" delete from tp_pm_inproduction pp where pp.barcode in(" + Insql + ")"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); sql = @" update TP_PM_INCHECKEDDETAIL p set p.INCHECKEDFLAG = '3' where p.INCHECKEDFLAG='9' and p.InCheckedID=" + inCheckedID; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); if (returnRows == 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } return returnRows; } /// /// 设置条码商标 /// /// public static int SaveBarCodeLogo(string barcode, int logoid, SUserInfo sUserInfo) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { // 转换条码 string sqlString = @"select FUN_CMN_GetBarCode(:barcode,null,:accountid) From DUAL"; OracleParameter[] paras1 = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input), }; barcode = oracleTrConn.GetSqlResultToStr(sqlString, paras1); OracleParameter[] Paras = null; object oldLogoID = null; object pid = null; string sql = ""; sql = @"select logoid from tp_pm_groutingdailydetail where barcode=:barcode"; oldLogoID = oracleTrConn.GetSqlResultToObj(sql, new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }); // 1.更新注浆明细 sql = @"update tp_pm_groutingdailydetail set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode"; Paras = new OracleParameter[] { new OracleParameter(":logoid",OracleDbType.Int32, logoid,ParameterDirection.Input), new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras); // 2.在产产品 sql = @"update tp_pm_inproduction set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode"; //Paras = new OracleParameter[] { // new OracleParameter(":logoid",OracleDbType.Int32, // logoid,ParameterDirection.Input), // new OracleParameter(":updateuserid",OracleDbType.Int32, // sUserInfo.UserID,ParameterDirection.Input), // new OracleParameter(":barcode",OracleDbType.Varchar2, // barcode,ParameterDirection.Input) // }; returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras); if (returnRows > 0) { sql = @"select ProcedureID from tp_pm_inproduction where barcode=:barcode"; pid = oracleTrConn.GetSqlResultToObj(sql, new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }); } // 3.在产回收站 sql = @"update tp_pm_inproductiontrash set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode"; //Paras = new OracleParameter[] { // new OracleParameter(":logoid",OracleDbType.Int32, // logoid,ParameterDirection.Input), // new OracleParameter(":updateuserid",OracleDbType.Int32, // sUserInfo.UserID,ParameterDirection.Input), // new OracleParameter(":barcode",OracleDbType.Varchar2, // barcode,ParameterDirection.Input) // }; returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras); // 4.在产临时表 sql = @"update tp_pm_inproduction_tmp set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode"; //Paras = new OracleParameter[] { // new OracleParameter(":logoid",OracleDbType.Int32, // logoid,ParameterDirection.Input), // new OracleParameter(":updateuserid",OracleDbType.Int32, // sUserInfo.UserID,ParameterDirection.Input), // new OracleParameter(":barcode",OracleDbType.Varchar2, // barcode,ParameterDirection.Input) // }; returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras); // 5.成品表 sql = @"update tp_pm_finishedproduct set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode"; //Paras = new OracleParameter[] { // new OracleParameter(":logoid",OracleDbType.Int32, // logoid,ParameterDirection.Input), // new OracleParameter(":updateuserid",OracleDbType.Int32, // sUserInfo.UserID,ParameterDirection.Input), // new OracleParameter(":barcode",OracleDbType.Varchar2, // barcode,ParameterDirection.Input) // }; returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras); // 6 在产盘点明细 sql = @"update TP_PM_InCheckedDetail set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode"; //Paras = new OracleParameter[] { // new OracleParameter(":logoid",OracleDbType.Int32, // logoid,ParameterDirection.Input), // new OracleParameter(":updateuserid",OracleDbType.Int32, // sUserInfo.UserID,ParameterDirection.Input), // new OracleParameter(":barcode",OracleDbType.Varchar2, // barcode,ParameterDirection.Input) // }; // ? returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras); // 7 半成品检验登记 sql = @"update TP_PM_SemiCheck set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode"; //Paras = new OracleParameter[] { // new OracleParameter(":logoid",OracleDbType.Int32, // logoid,ParameterDirection.Input), // new OracleParameter(":updateuserid",OracleDbType.Int32, // sUserInfo.UserID,ParameterDirection.Input), // new OracleParameter(":barcode",OracleDbType.Varchar2, // barcode,ParameterDirection.Input) // }; // ? returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras); // 8 废弃产品 sql = @"update TP_PM_ScrapProduct set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode"; //Paras = new OracleParameter[] { // new OracleParameter(":logoid",OracleDbType.Int32, // logoid,ParameterDirection.Input), // new OracleParameter(":updateuserid",OracleDbType.Int32, // sUserInfo.UserID,ParameterDirection.Input), // new OracleParameter(":barcode",OracleDbType.Varchar2, // barcode,ParameterDirection.Input) // }; // ? returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras); // 9 在产生产数据 sql = @"update TP_PM_ProductionDataIn set Triggerflag=1, logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode"; //Paras = new OracleParameter[] { // new OracleParameter(":logoid",OracleDbType.Int32, // logoid,ParameterDirection.Input), // new OracleParameter(":updateuserid",OracleDbType.Int32, // sUserInfo.UserID,ParameterDirection.Input), // new OracleParameter(":barcode",OracleDbType.Varchar2, // barcode,ParameterDirection.Input) // }; // ? returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras); // 10 生产数据 sql = @"update TP_PM_ProductionData set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode"; //Paras = new OracleParameter[] { // new OracleParameter(":logoid",OracleDbType.Int32, // logoid,ParameterDirection.Input), // new OracleParameter(":updateuserid",OracleDbType.Int32, // sUserInfo.UserID,ParameterDirection.Input), // new OracleParameter(":barcode",OracleDbType.Varchar2, // barcode,ParameterDirection.Input) // }; // ? returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras); // 变更履历 sql = "INSERT INTO TP_PM_LOGOCHANGEDRECORD\n" + " (BARCODE\n" + " ,OLDLOGOID\n" + " ,NEWLOGOID\n" + " ,PROCEDUREID\n" + " ,REMARKS\n" + " ,ACCOUNTID\n" + " ,CREATETIME\n" + " ,CREATEUSERID)\n" + "VALUES\n" + " (:BARCODE\n" + " ,:OLDLOGOID\n" + " ,:NEWLOGOID\n" + " ,:PROCEDUREID\n" + " ,NULL\n" + " ,:ACCOUNTID\n" + " ,SYSDATE\n" + " ,:CREATEUSERID)"; Paras = new OracleParameter[] { new OracleParameter(":OLDLOGOID",OracleDbType.Int32, oldLogoID,ParameterDirection.Input), new OracleParameter(":NEWLOGOID",OracleDbType.Int32, logoid,ParameterDirection.Input), new OracleParameter(":PROCEDUREID",OracleDbType.Int32, pid,ParameterDirection.Input), new OracleParameter(":ACCOUNTID",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input), new OracleParameter(":CREATEUSERID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":BARCODE",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras); //if (returnRows == 0) //{ // oracleTrConn.Rollback(); // oracleTrConn.Disconnect(); //} //else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } return returnRows; } /// /// 设置产成品商标 /// /// /// /// /// public static int SetFinishedLogo(string[] barcodes, int logoid, SUserInfo sUserInfo) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { OracleParameter[] Paras = null; object oldLogoID = null; object gdid = null; //object pid = null; string sql = ""; DataTable dataTable = null; foreach (string barcode in barcodes) { sql = @"select groutingdailydetailid, logoid from tp_pm_groutingdailydetail where barcode=:barcode"; dataTable = oracleTrConn.GetSqlResultToDt(sql, new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }); if (dataTable == null || dataTable.Rows.Count == 0) { continue; } gdid = dataTable.Rows[0]["groutingdailydetailid"]; oldLogoID = dataTable.Rows[0]["logoid"]; // 1.更新注浆明细 sql = @"update tp_pm_groutingdailydetail set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode"; Paras = new OracleParameter[] { new OracleParameter(":logoid",OracleDbType.Int32, logoid,ParameterDirection.Input), new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); // 5.成品表 sql = @"update tp_pm_finishedproduct set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode"; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); // 变更履历 sql = "INSERT INTO TP_PM_LOGOCHANGEDRECORD\n" + " (BARCODE\n" + " ,OLDLOGOID\n" + " ,NEWLOGOID\n" + //" ,PROCEDUREID\n" + " ,REMARKS\n" + " ,ACCOUNTID\n" + " ,CREATETIME\n" + " ,CREATEUSERID)\n" + "VALUES\n" + " (:BARCODE\n" + " ,:OLDLOGOID\n" + " ,:NEWLOGOID\n" + //" ,:PROCEDUREID\n" + " ,NULL\n" + " ,:ACCOUNTID\n" + " ,SYSDATE\n" + " ,:CREATEUSERID)"; Paras = new OracleParameter[] { new OracleParameter(":OLDLOGOID",OracleDbType.Int32, oldLogoID,ParameterDirection.Input), new OracleParameter(":NEWLOGOID",OracleDbType.Int32, logoid,ParameterDirection.Input), //new OracleParameter(":PROCEDUREID",OracleDbType.Int32, // pid,ParameterDirection.Input), new OracleParameter(":ACCOUNTID",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input), new OracleParameter(":CREATEUSERID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":BARCODE",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); } //if (returnRows == 0) //{ // oracleTrConn.Rollback(); // oracleTrConn.Disconnect(); //} //else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } return returnRows; } /// /// 设置产成品订单 /// /// /// /// /// public static int SetHandoveredOrder(string[] barcodes, int orderID, SUserInfo sUserInfo) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { string sql = @"update tp_pm_finishedproduct set FHOrderID=:FHOrderID,updateuserid=:updateuserid where barcode=:barcode and FHOrderID is not null"; OracleParameter[] Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.Varchar2, "",ParameterDirection.Input), new OracleParameter(":FHOrderID",OracleDbType.Int32, orderID,ParameterDirection.Input), new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input) }; foreach (string barcode in barcodes) { Paras[0].Value = barcode; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); } oracleTrConn.Commit(); oracleTrConn.Disconnect(); } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } return returnRows; } #endregion /// /// 添加生产数据 /// /// 连接对象 /// 账务日期 /// 生产数据 /// 用户基本信息 /// string /// /// 陈冰 2014.09.18 新建 /// private static string AddProductionDataWaster(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag) { #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号 string selectSql = ""; string returnVal = ""; if (productionData.NodeType == (int)Constant.ProcedureNodeType.Begin)//开始节点时从注浆登记取值 { selectSql = @"select TP_PM_GroutingDailyDetail.GroutingDate, TP_PM_GroutingDailyDetail.UserID as GroutingUserID, TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode, TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum, TP_PM_GroutingDailyDetail.GroutingMouldCode, TP_PM_GroutingDailyDetail.MouldCode, TP_PM_GroutingDailyDetail.GroutingDailyID, TP_PM_GroutingDailyDetail.GroutingDailyDetailID, TP_PM_GroutingDailyDetail.GroutingLineID, TP_PM_GroutingDailyDetail.GroutingLineCode, TP_PM_GroutingDailyDetail.GroutingLineName, TP_PM_GroutingDailyDetail.GroutingLineDetailID, TP_PM_GroutingDailyDetail.SpecialRepairflag, (select GMouldTypeID from TP_PM_GroutingDaily where TP_PM_GroutingDaily.GroutingDailyID = TP_PM_GroutingDailyDetail.GroutingDailyID) as GMouldTypeID, (select CanManyTimes from TP_PM_GroutingDaily where TP_PM_GroutingDaily.GroutingDailyID = TP_PM_GroutingDailyDetail.GroutingDailyID) as CanManyTimes, 0 as IsReFire from TP_PM_GroutingDailyDetail where TP_PM_GroutingDailyDetail.barcode=:barcode"; } else { selectSql = @"select GroutingDate, userid as GroutingUserID, usercode as GroutingUserCode, Groutingcount as GroutingNum, GroutingMouldCode, MouldCode, GroutingDailyID, GroutingDailyDetailID, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, SpecialRepairflag, 0 as IsReFire, logoid from TP_PM_GroutingDailyDetail where barcode=:barcode "; } OracleParameter[] selectparas = new OracleParameter[] { new OracleParameter(":barcode",productionData.Barcode), }; DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas); DateTime GroutingDate = new DateTime(); int GroutingUserID = 0, GroutingNum = 0, GroutingDailyID = 0, GroutingDailyDetailID = 0, GroutingLineID = 0, GMouldTypeID = 0, CanManyTimes = 0, GroutingLineDetailID = 0, SpecialRepairflag = 0; string GroutingUserCode = "", GroutingMouldCode = "", MouldCode = "", GroutingLineCode = "", GroutingLineName = ""; int IsReFire = 0; int? logoID = null; if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0) { GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]); GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]); GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString(); GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]); GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString(); MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString(); GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]); GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]); GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]); GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString(); GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString(); GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]); CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]); GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]); SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]); IsReFire = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["IsReFire"]); if (IsReFire > 0) //大于零代表重烧过 { productionData.IsReFire = IsReFire; productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect; } if (dsGroutingProduct.Tables[0].Rows[0]["logoID"].ToString() != "") { logoID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["logoID"]); } //if (productionData.LogoID != null) //当前工序有商标 //{ // if (logoID != productionData.LogoID && productionData.LogoID != 0) // { // logoID = productionData.LogoID; // //根据明细ID.update // selectSql = "update TP_PM_GroutingDailyDetail set logoid=:logoid where GroutingDailyDetailID=" + GroutingDailyDetailID; // OracleParameter[] paras2 = new OracleParameter[] { // new OracleParameter(":logoid",productionData.LogoID) // }; // oracleTrConn.ExecuteNonQuery(selectSql, paras2); // } //} returnVal = SpecialRepairflag.ToString(); } #endregion #region 更新窑炉窑车属性 if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4) { DataSet ds = GetKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo); if (ds != null) { if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息 { productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]); productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString(); productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString(); productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]); productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString(); productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString(); productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString(); productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]); } } } #endregion #region SQL string sql = "insert into tp_pm_productiondataIn" + " (productiondataid," + " barcode," + " centralizedbatchno," + " productionlineid," + " productionlinecode," + " productionlinename," + " procedureid," + " procedurecode," + " procedurename," + " proceduremodel," + " modeltype," + " piecetype," + " isreworked," + " nodetype," + " ispublicbody," + " isrefire," + " organizationid," + " goodsid," + " goodscode," + " goodsname," + " userid," + " usercode," + " username," + " kilnid," + " kilncode," + " kilnname," + " kilncarid," + " kilncarcode," + " kilncarname," + " kilncarbatchno," + " kilncarposition," + " reworkprocedureid," + " reworkprocedurecode," + " reworkprocedurename," + " remarks," + " accountdate," + " accountid," + " GoodsLevelID," + " GoodsLevelTypeID," + " createuserid," + " updateuserid," + " GroutingDate," + " GroutingUserID," + " GroutingUserCode," + " GroutingNum," + " GroutingMouldCode," + " MouldCode," + "GroutingDailyID," + "GroutingDailyDetailID," + "GroutingLineID," + " GroutingLineCode," + "GroutingLineName," + "GMouldTypeID," + "CanManyTimes," + "GroutingLineDetailID," + "SpecialRepairflag," + "ClassesSettingID," + "LogoID" + ")" + " values" + " (:productiondataid," + " :barcode," + " :centralizedbatchno," + " :productionlineid," + " :productionlinecode," + " :productionlinename," + " :procedureid," + " :procedurecode," + " :procedurename," + " :proceduremodel," + " :modeltype," + " :piecetype," + " :isreworked," + " :nodetype," + " :ispublicbody," + " :isrefire," + " :organizationid," + " :goodsid," + " :goodscode," + " :goodsname," + " :userid," + " :usercode," + " :username," + " :kilnid," + " :kilncode," + " :kilnname," + " :kilncarid," + " :kilncarcode," + " :kilncarname," + " :kilncarbatchno," + " :kilncarposition," + " :reworkprocedureid," + " :reworkprocedurecode," + " :reworkprocedurename," + " :remarks," + " :accountdata," + " :accountid," + " :GoodsLevelID," + " :GoodsLevelTypeID," + " :createuserid," + " :updateuserid," + " :groutingdate," + " :groutinguserid," + " :groutingusercode," + " :groutingnum," + " :groutingmouldcode," + " :mouldcode," + ":groutingdailyid," + ":groutingdailydetailid," + ":groutinglineid," + " :groutinglinecode," + ":groutinglinename," + ":gmouldtypeid," + ":canmanytimes," + ":groutinglinedetailid," + ":specialRepairflag," + ":classesSettingID," + ":logoID" + ")"; #endregion #region OracleParameter OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":classesSettingID",productionData.ClassesSettingID), new OracleParameter(":productiondataid",productionData.ProductionDataID), new OracleParameter(":barcode",productionData.Barcode), new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo), new OracleParameter(":productionlineid",productionData.ProductionLineID), new OracleParameter(":productionlinecode",productionData.ProductionLineCode), new OracleParameter(":productionlinename",productionData.ProductionLineName), new OracleParameter(":procedureid",productionData.ProcedureID), new OracleParameter(":procedurecode",productionData.ProcedureCode), new OracleParameter(":procedurename",productionData.ProcedureName), new OracleParameter(":proceduremodel",productionData.ProcedureModel), new OracleParameter(":modeltype",productionData.ModelType), new OracleParameter(":piecetype",productionData.PieceType), new OracleParameter(":isreworked",productionData.IsReworked), new OracleParameter(":nodetype",productionData.NodeType), new OracleParameter(":ispublicbody",productionData.IsPublicBody), new OracleParameter(":isrefire",productionData.IsReFire), new OracleParameter(":organizationid",productionData.OrganizationID), new OracleParameter(":goodsid",productionData.GoodsID), new OracleParameter(":goodscode",productionData.GoodsCode), new OracleParameter(":goodsname",productionData.GoodsName), new OracleParameter(":userid",productionData.UserID), new OracleParameter(":usercode",productionData.UserCode), new OracleParameter(":username",productionData.UserName), new OracleParameter(":kilnid",productionData.KilnID), new OracleParameter(":kilncode",productionData.KilnCode), new OracleParameter(":kilnname",productionData.KilnName), new OracleParameter(":kilncarid",productionData.KilnCarID), new OracleParameter(":kilncarcode",productionData.KilnCarCode), new OracleParameter(":kilncarname",productionData.KilnCarName), new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo), new OracleParameter(":kilncarposition",productionData.KilnCarPosition), new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID), new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode), new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName), new OracleParameter(":remarks",productionData.Remarks), new OracleParameter(":accountdata",accountDate), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID), new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":groutingdate",GroutingDate), new OracleParameter(":groutinguserid",GroutingUserID), new OracleParameter(":groutingusercode",GroutingUserCode), new OracleParameter(":groutingnum",GroutingNum), new OracleParameter(":groutingmouldcode",GroutingMouldCode), new OracleParameter(":mouldcode",MouldCode), new OracleParameter(":groutingdailyid",GroutingDailyID), new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID), new OracleParameter(":groutinglineid",GroutingLineID), new OracleParameter(":groutinglinecode",GroutingLineCode), new OracleParameter(":groutinglinename",GroutingLineName), new OracleParameter(":gmouldtypeid",GMouldTypeID), new OracleParameter(":canmanytimes",CanManyTimes), new OracleParameter(":groutinglinedetailid",GroutingLineDetailID), new OracleParameter(":specialRepairflag",SpecialRepairflag), new OracleParameter(":logoID",logoID), }; #endregion foreach (OracleParameter para in paras) { if (string.IsNullOrEmpty(para.Value + "")) { para.Value = DBNull.Value; } } int result = oracleTrConn.ExecuteNonQuery(sql, paras); OutSpecialRepairflag = returnVal; // 失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 成功返回null return null; } #region 保存半检登记 /// /// 保存半检登记 /// /// 半检实体类 /// 用户基本信息 /// ServiceResultEntity /// /// 王鑫 2016.06.27 新建 /// public static ServiceResultEntity AddSemiCheck(SemiCheckEntity[] entityobj, SUserInfo sUserInfo) { IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); oracleTrConn.IgnoreCase = false; ServiceResultEntity resultEntity = new ServiceResultEntity(); try { oracleTrConn.Connect(); SemiCheckEntity entity = entityobj[0]; string errMsg = ""; if (entity.SemiCheckCategory == 1) // 半检登记 { errMsg = AddNormalSemiCheck(oracleTrConn, entity, sUserInfo); } else if (entity.SemiCheckCategory == 2)// 复检登记 { errMsg = AddReSemiCheck(oracleTrConn, entity, sUserInfo); } else if (entity.SemiCheckCategory == 3)// 撤销复检 { errMsg = AddCancelSemiCheck(oracleTrConn, entity, sUserInfo); } // 没有错误 提交事务 if (string.IsNullOrEmpty(errMsg)) { oracleTrConn.Commit(); } else { resultEntity.Message = errMsg; } } catch (Exception ex) { oracleTrConn.Rollback(); throw ex; } finally { // 释放资源 if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Disconnect(); } } return resultEntity; } #endregion /// /// 半检数据 /// /// 数据连接对象 /// 半检实体类 /// 用户基本信息 /// string /// /// 王鑫 2016.06.27 新建 /// private static string AddNormalSemiCheck(IDBTransaction oracleTrConn, SemiCheckEntity entity, SUserInfo sUserInfo) { try { // 获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); string errMsg = string.Empty; // 本批采集的批次号 string centralizedBatchNo = System.Guid.NewGuid().ToString(); // 条码 string barcode = entity.BarCode; if (string.IsNullOrEmpty(barcode)) { throw new Exception("传入的条码号为空"); } // 半检工号ID int workUserID = Convert.ToInt32(entity.SemiCheckUserID); // 半检工号编码 string workUserCode = entity.SemiCheckUserCode; // 查询新插入的半检数据ID string sql = "select SEQ_PM_SemiCheck_ID.nextval from dual"; string idStr = ""; if (entity.SemiCheckEditType == 1) //新增 { idStr = oracleTrConn.GetSqlResultToStr(sql); } else if (entity.SemiCheckEditType == 2) //编辑返工 { if (entity.SemiCheckType != "0") //正常 { idStr = oracleTrConn.GetSqlResultToStr(sql); } } else if (entity.SemiCheckEditType == 3) //编辑不合格 { if (entity.SemiCheckType != "0") //正常 { idStr = oracleTrConn.GetSqlResultToStr(sql); } } // 保存时再验证,前台已有缺陷不能为空的验证,但还是产生了无责任和缺陷记录的数据,后台保存时增加验证。 if (!string.IsNullOrEmpty(idStr) && (entity.SemiCheckDefects == null || entity.SemiCheckDefects.Count == 0)) { errMsg = "缺陷责任记录不能为空"; return errMsg; } if (entity.SemiCheckEditType == 1) //新增 { #region 校验条码有效性 errMsg = CheckBarcodeByNew(oracleTrConn, barcode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 添加半检数据 entity.SemiCheckID = Convert.ToInt32(idStr); if (entity.SemiCheckType == "2") { errMsg = AddSemiCheckDataNoPass(oracleTrConn, entity, sUserInfo); } else { errMsg = AddSemiCheckData(oracleTrConn, entity, sUserInfo); } if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 条码有缺陷 #region 是次品 添加废弃产品 string ResponProcedureidStr = ""; if (entity.SemiCheckType == "2") //新建时不合格,直接报损 { #region 添加废弃产品 ScrapProductEntity scrapProduct = new ScrapProductEntity(); #region 属性赋值 scrapProduct.BarCode = entity.BarCode; scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode(); // 不能责任人吗? TODO 单独责任时,没有插入废品数据。 //scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode(); scrapProduct.ResponType = (int)Constant.ScrapResponType.Person; scrapProduct.ScrapDate = accountDate;// sysdate scrapProduct.Rreason = Constant.SCRAPTYPE_NOPASS; scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode(); scrapProduct.Auditor = sUserInfo.UserID; scrapProduct.AuditlDate = accountDate;// sysdate scrapProduct.AccountDate = accountDate; sql = "select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=" + sUserInfo.AccountID; DataSet ds = oracleTrConn.GetSqlResultToDs(sql); if (ds != null && ds.Tables[0].Rows.Count > 0) { scrapProduct.GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]); } scrapProduct.GoodsLevelTypeID = 13; //scrapProduct.IsPublicBody = IsPubilcByBarCode(oracleTrConn, entity.BarCode); // 查询新插入的废弃ID string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.nextval from dual"; ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql); scrapProduct.ScrapProductID = Convert.ToInt32(ResponProcedureidStr); scrapProduct.ScrapType = 2; #endregion // 保存报废 errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo); // 保存失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion // 存在缺陷 插入缺陷表 if (entity.SemiCheckDefects != null) { int row = 0; foreach (SemiCheckDefectEntity semiCheckDefect in entity.SemiCheckDefects) { if (row == 0) { #region 保存缺陷 semiCheckDefect.SemiCheckID = Convert.ToInt32(idStr); semiCheckDefect.ScrapResponFlag = string.IsNullOrEmpty(semiCheckDefect.ScrapResponFlag) ? "0" : semiCheckDefect.ScrapResponFlag; // 保存缺陷 errMsg = AddSemiCheckDefect(oracleTrConn, semiCheckDefect, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 是不合格 添加废弃责任工序 if (entity.SemiCheckType == "2") { //if (semiCheckDefect.DefectProcedureID != null) { #region 添加责任工序 ResponProcedureEntity responProce = new ResponProcedureEntity(); // 新建-不合格 获取生产线及生产数据ID sql = "select ProductionLineID,ProductionLineCode,ProductionLineName,ProductionDataID from TP_PM_InProduction where barcode=:barcode"; OracleParameter[] oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), }; DataSet ds = oracleTrConn.GetSqlResultToDs(sql, oracleParameters); if (ds != null && ds.Tables[0].Rows.Count > 0) { responProce.ProductionDataID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionDataID"]); responProce.ProductionLineID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionLineID"]); responProce.ProductionLineCode = ds.Tables[0].Rows[0]["ProductionLineCode"].ToString(); responProce.ProductionLineName = ds.Tables[0].Rows[0]["ProductionLineName"].ToString(); } //新建-不合格 获取生产线及生产数据ID end #region 属性赋值 responProce.BarCode = entity.BarCode; responProce.ProcedureID = semiCheckDefect.DefectProcedureID; responProce.ProcedureCode = semiCheckDefect.DefectProcedureCode; responProce.ProcedureName = semiCheckDefect.DefectProcedureName; responProce.UserID = semiCheckDefect.DefectUserID; responProce.UserCode = semiCheckDefect.DefectUserCode; responProce.UserName = semiCheckDefect.DefectUserName; responProce.Remarks = semiCheckDefect.Remarks; responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr); #endregion // 保存责任工序 errMsg = AddSemiCheckResponProcedure(oracleTrConn, responProce, semiCheckDefect, sUserInfo); // 保存失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } } #endregion } row++; } } #endregion #region 条码是不合格 删除在产产品数据 if (entity.SemiCheckType == "2") //新建时不合格 { // 1.在产表产品设置产品等级【13不合格】,半检登记ID=记录的半检登记ID。 sql = @"update TP_PM_InProduction set GoodsLevelID= ( select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid ) ,GoodsLevelTypeID=13,SemiCheckID=:SemiCheckID,updateuserid=:updateuserid where barcode=:barcode"; OracleParameter[] oracleParameters = new OracleParameter[] { //new OracleParameter(":GoodsLevelID",entity.GoodsLevelID), //new OracleParameter(":GoodsLevelTypeID",entity.GoodsLevelTypeID), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":SemiCheckID",Convert.ToInt32(idStr)), new OracleParameter(":barcode",entity.BarCode), // new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), }; int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); // 2.将在产数据保存到在产回收站表中(产品等级【13不合格】,半检登记ID=记录的半检登记ID)。 string sqlInsert = @"insert into TP_PM_InProductionTrash ( BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, CreateUserID, UpdateUserID, SpecialRepairflag, FlowProcedureID, FlowProcedureTime, ProcedureID, ProcedureTime, ProductionDataID, logoid, ISREWORKFLAG, SEMICHECKID ) select BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, -- GoodsLevelID, --GoodsLevelTypeID, ( select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid ) ,13, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, :CreateUserID, :UpdateUserID, SpecialRepairflag, FlowProcedureID, FlowProcedureTime, FlowProcedureID, ProcedureTime, ProductionDataID, logoid, ISREWORKFLAG, SEMICHECKID from TP_PM_InProduction where barcode=:barcode "; oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":CreateUserID",sUserInfo.UserID), new OracleParameter(":UpdateUserID",sUserInfo.UserID), new OracleParameter(":accountid",sUserInfo.AccountID), }; result += oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters); // 删除在产数据 sql = "delete tp_pm_inproduction where barcode = :barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), }; result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); } else if (entity.SemiCheckType == "1") //返工 { sql = @"update TP_PM_InProduction set IsReworkFlag=1,SemiCheckID=:SemiCheckID,updateuserid=:updateuserid where barcode=:barcode"; OracleParameter[] oracleParameters = new OracleParameter[] { new OracleParameter(":SemiCheckID",Convert.ToInt32(idStr)), new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":updateuserid",sUserInfo.UserID), }; int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); } #endregion } else if (entity.SemiCheckEditType == 2) //编辑返工 { #region 校验条码有效性 errMsg = CheckBarcodeByEditRework(oracleTrConn, barcode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 删除当前半检数据 errMsg = SetSemiCheckDataValueFlag(oracleTrConn, entity, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion if (entity.SemiCheckType != "0") //正常 { #region 添加半检数据 entity.SemiCheckID = Convert.ToInt32(idStr); errMsg = AddSemiCheckData(oracleTrConn, entity, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #region 条码有缺陷 #region 是次品 添加废弃产品 string ResponProcedureidStr = ""; if (entity.SemiCheckType == "2") //新建时不合格,直接报损 { #region 添加废弃产品 ScrapProductEntity scrapProduct = new ScrapProductEntity(); #region 属性赋值 scrapProduct.BarCode = entity.BarCode; scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode(); scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode(); scrapProduct.ScrapDate = accountDate; scrapProduct.Rreason = Constant.SCRAPTYPE_NOPASS; scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode(); scrapProduct.Auditor = sUserInfo.UserID; scrapProduct.AuditlDate = accountDate; scrapProduct.AccountDate = accountDate; //scrapProduct.GoodsLevelID = entity.GoodsLevelID; //scrapProduct.GoodsLevelTypeID = entity.GoodsLevelTypeID; sql = "select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=" + sUserInfo.AccountID; DataSet ds = oracleTrConn.GetSqlResultToDs(sql); if (ds != null && ds.Tables[0].Rows.Count > 0) { scrapProduct.GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]); } scrapProduct.GoodsLevelTypeID = 13; scrapProduct.IsPublicBody = IsPubilcByBarCode(oracleTrConn, entity.BarCode); // 查询新插入的废弃ID string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.nextval from dual"; ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql); scrapProduct.ScrapProductID = Convert.ToInt32(ResponProcedureidStr); scrapProduct.ScrapType = 2; #endregion // 保存报废 errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo); // 保存失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion // 存在缺陷 插入缺陷表 if (entity.SemiCheckDefects != null) { foreach (SemiCheckDefectEntity semiCheckDefect in entity.SemiCheckDefects) { #region 保存缺陷 semiCheckDefect.SemiCheckID = Convert.ToInt32(idStr); semiCheckDefect.ScrapResponFlag = string.IsNullOrEmpty(semiCheckDefect.ScrapResponFlag) ? "0" : semiCheckDefect.ScrapResponFlag; // 保存缺陷 errMsg = AddSemiCheckDefect(oracleTrConn, semiCheckDefect, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 是不合格 添加废弃责任工序 if (entity.SemiCheckType == "2") { //if (semiCheckDefect.DefectProcedureID != null) { #region 添加责任工序 ResponProcedureEntity responProce = new ResponProcedureEntity(); // 获取生产线及生产数据ID sql = "select ProductionLineID,ProductionLineCode,ProductionLineName,ProductionDataID from TP_PM_InProduction where barcode=:barcode"; OracleParameter[] oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), }; DataSet ds = oracleTrConn.GetSqlResultToDs(sql, oracleParameters); if (ds != null && ds.Tables[0].Rows.Count > 0) { responProce.ProductionDataID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionDataID"]); responProce.ProductionLineID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionLineID"]); responProce.ProductionLineCode = ds.Tables[0].Rows[0]["ProductionLineCode"].ToString(); responProce.ProductionLineName = ds.Tables[0].Rows[0]["ProductionLineName"].ToString(); } //获取生产线及生产数据ID end #region 属性赋值 responProce.BarCode = entity.BarCode; responProce.ProcedureID = semiCheckDefect.DefectProcedureID; responProce.ProcedureCode = semiCheckDefect.DefectProcedureCode; responProce.ProcedureName = semiCheckDefect.DefectProcedureName; responProce.UserID = semiCheckDefect.DefectUserID; responProce.UserCode = semiCheckDefect.DefectUserCode; responProce.UserName = semiCheckDefect.DefectUserName; responProce.Remarks = semiCheckDefect.Remarks; responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr); #endregion // 保存责任工序 errMsg = AddSemiCheckResponProcedure(oracleTrConn, responProce, semiCheckDefect, sUserInfo); // 保存失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } } #endregion } } #endregion #region 条码是不合格 删除在产产品数据 if (entity.SemiCheckType == "2") //编辑时不合格 { // 1.在产表产品设置产品等级【13不合格】,半检登记ID=记录的半检登记ID。 sql = @"update TP_PM_InProduction set GoodsLevelID= ( select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid ),GoodsLevelTypeID=13,SemiCheckID=:SemiCheckID,IsReworkFlag=0, updateuserid=:updateuserid where barcode=:barcode"; OracleParameter[] oracleParameters = new OracleParameter[] { //new OracleParameter(":GoodsLevelID",entity.GoodsLevelID), //new OracleParameter(":GoodsLevelTypeID",entity.GoodsLevelTypeID), new OracleParameter(":SemiCheckID",Convert.ToInt32(idStr)), new OracleParameter(":barcode",entity.BarCode), //new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":accountid",sUserInfo.AccountID), }; int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); // 2.将在产数据保存到在产回收站表中(产品等级【13不合格】,半检登记ID=记录的半检登记ID)。 string sqlInsert = @"insert into TP_PM_InProductionTrash ( BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, CreateUserID, UpdateUserID, SpecialRepairflag, FlowProcedureID, FlowProcedureTime, ProcedureID, ProcedureTime, ProductionDataID, logoid, SEMICHECKID ) select BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, -- GoodsLevelID, --GoodsLevelTypeID, ( select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid ) ,13, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, :CreateUserID, :UpdateUserID, SpecialRepairflag, FlowProcedureID, FlowProcedureTime, FlowProcedureID, ProcedureTime, ProductionDataID, logoid, :SemiCheckID from TP_PM_InProduction where barcode=:barcode "; oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":CreateUserID",sUserInfo.UserID), new OracleParameter(":UpdateUserID",sUserInfo.UserID), new OracleParameter(":SemiCheckID",entity.SemiCheckID), new OracleParameter(":accountid",sUserInfo.AccountID), }; result += oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters); // 删除在产数据 sql = "delete tp_pm_inproduction where barcode = :barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), }; result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); } else if (entity.SemiCheckType == "1") //返工 { sql = @"update TP_PM_InProduction set IsReworkFlag=1,SemiCheckID=:SemiCheckID,updateuserid=:updateuserid where barcode=:barcode"; OracleParameter[] oracleParameters = new OracleParameter[] { new OracleParameter(":SemiCheckID",Convert.ToInt32(idStr)), new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":updateuserid",sUserInfo.UserID), }; int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); } else if (entity.SemiCheckType == "0") //正常 { sql = @"update TP_PM_InProduction set IsReworkFlag=0,SemiCheckID=null,updateuserid=:updateuserid where barcode=:barcode"; OracleParameter[] oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":updateuserid",sUserInfo.UserID), }; int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); } #endregion } else if (entity.SemiCheckEditType == 3) //编辑不合格 { #region 校验条码有效性 errMsg = CheckBarcodeByEditNoPass(oracleTrConn, barcode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 删除当前半检数据 errMsg = SetSemiCheckDataValueFlag(oracleTrConn, entity, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion if (entity.SemiCheckType != "0") //正常 { #region 添加半检数据 entity.SemiCheckID = Convert.ToInt32(idStr); errMsg = AddSemiCheckDataTrash(oracleTrConn, entity, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #region 条码是不合格 删除在产产品数据 OracleParameter[] spParameters = null; int spResult = 0; if (entity.SemiCheckType == "2") //编辑时不合格 { #region 1.废弃产品表中对应的总单数据和明细数据valueflag='0'。 string sqlString = "select max(sp.scrapproductid) scrapproductid\n" + " from TP_PM_ScrapProduct sp\n" + " where sp.barcode = :barcode\n" + " and sp.auditstatus = 1\n" + " and sp.valueflag = '1'\n" + " and sp.scraptype = '2'"; spParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), }; string scrapproductid = oracleTrConn.GetSqlResultToStr(sqlString, spParameters); sqlString = @"update TP_PM_ScrapProduct set valueflag='0', updateuserid=:updateuserid, backouttime=sysdate where scrapproductid=:scrapproductid"; spParameters = new OracleParameter[] { new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":scrapproductid",scrapproductid), }; spResult = oracleTrConn.ExecuteNonQuery(sqlString, spParameters); sqlString = @"update TP_PM_ResponProcedure set valueflag='0', updateuserid=:updateuserid where scrapproductid=:scrapproductid"; //oracleParameters = new OracleParameter[] { // new OracleParameter(":barcode",entity.BarCode), //}; spResult += oracleTrConn.ExecuteNonQuery(sqlString, spParameters); //sql = @"update TP_PM_ScrapProduct set valueflag='0' where barcode=:barcode"; //OracleParameter[] oracleParameters = new OracleParameter[] { // new OracleParameter(":barcode",entity.BarCode), //}; //int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); //sql = @"update TP_PM_ResponProcedure set valueflag='0' where barcode=:barcode"; //oracleParameters = new OracleParameter[] { // new OracleParameter(":barcode",entity.BarCode), //}; //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); ////sql = @"update TP_PM_ScrapResponsible set valueflag='0' where barcode=:barcode"; ////oracleParameters = new OracleParameter[] { //// new OracleParameter(":barcode",entity.BarCode), ////}; ////result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); #endregion #region 2.修改在产回收站表中的数据(产品等级【13不合格】,半检登记ID=新记录的半检登记ID)。 sql = @"update TP_PM_InProductionTrash set GoodsLevelID= ( select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid ),GoodsLevelTypeID=13,SemiCheckID=:SemiCheckID where barcode=:barcode"; OracleParameter[] oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":accountid",sUserInfo.AccountID), //new OracleParameter(":GoodsLevelTypeID",entity.GoodsLevelTypeID), new OracleParameter(":SemiCheckID",entity.SemiCheckID), }; int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); #endregion #region 条码有缺陷 #region 是次品 添加废弃产品 string ResponProcedureidStr = ""; if (entity.SemiCheckType == "2") //新建时不合格,直接报损 { #region 添加废弃产品 ScrapProductEntity scrapProduct = new ScrapProductEntity(); #region 属性赋值 scrapProduct.BarCode = entity.BarCode; scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode(); scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode(); scrapProduct.ScrapDate = accountDate; scrapProduct.Rreason = Constant.SCRAPTYPE_NOPASS; scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode(); scrapProduct.Auditor = sUserInfo.UserID; scrapProduct.AuditlDate = accountDate; scrapProduct.AccountDate = accountDate; sql = "select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=" + sUserInfo.AccountID; DataSet ds = oracleTrConn.GetSqlResultToDs(sql); if (ds != null && ds.Tables[0].Rows.Count > 0) { scrapProduct.GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]); } scrapProduct.GoodsLevelTypeID = 13; //scrapProduct.GoodsLevelID = entity.GoodsLevelID; //scrapProduct.GoodsLevelTypeID = entity.GoodsLevelTypeID; scrapProduct.IsPublicBody = IsPubilcByBarCode(oracleTrConn, entity.BarCode); // 查询新插入的废弃ID string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.nextval from dual"; ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql); scrapProduct.ScrapProductID = Convert.ToInt32(ResponProcedureidStr); scrapProduct.ScrapType = 2; #endregion // 保存报废 errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo); // 保存失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion // 存在缺陷 插入缺陷表 if (entity.SemiCheckDefects != null) { foreach (SemiCheckDefectEntity semiCheckDefect in entity.SemiCheckDefects) { #region 保存缺陷 semiCheckDefect.SemiCheckID = Convert.ToInt32(idStr); semiCheckDefect.ScrapResponFlag = string.IsNullOrEmpty(semiCheckDefect.ScrapResponFlag) ? "0" : semiCheckDefect.ScrapResponFlag; // 保存缺陷 errMsg = AddSemiCheckDefect(oracleTrConn, semiCheckDefect, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion #region 是不合格 添加废弃责任工序 if (entity.SemiCheckType == "2") { //if (semiCheckDefect.DefectProcedureID != null) { #region 添加责任工序 ResponProcedureEntity responProce = new ResponProcedureEntity(); // 取生产线及生产数据ID sql = "select ProductionLineID,ProductionLineCode,ProductionLineName,ProductionDataID from TP_PM_InProductionTrash where barcode=:barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), }; DataSet ds = oracleTrConn.GetSqlResultToDs(sql, oracleParameters); if (ds != null && ds.Tables[0].Rows.Count > 0) { responProce.ProductionDataID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionDataID"]); responProce.ProductionLineID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionLineID"]); responProce.ProductionLineCode = ds.Tables[0].Rows[0]["ProductionLineCode"].ToString(); responProce.ProductionLineName = ds.Tables[0].Rows[0]["ProductionLineName"].ToString(); } //获取生产线及生产数据ID end #region 属性赋值 responProce.BarCode = entity.BarCode; //responProce.ProductionDataID = semiCheckDefect.ProductionDataID; //responProce.ProductionLineID = semiCheckDefect.ProductionLineID; //responProce.ProductionLineCode = semiCheckDefect.ProductionLineCode; //responProce.ProductionLineName = semiCheckDefect.ProductionLineName; responProce.ProcedureID = semiCheckDefect.DefectProcedureID; responProce.ProcedureCode = semiCheckDefect.DefectProcedureCode; responProce.ProcedureName = semiCheckDefect.DefectProcedureName; responProce.UserID = semiCheckDefect.DefectUserID; responProce.UserCode = semiCheckDefect.DefectUserCode; responProce.UserName = semiCheckDefect.DefectUserName; responProce.Remarks = semiCheckDefect.Remarks; responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr); #endregion // 保存责任工序 errMsg = AddSemiCheckResponProcedure(oracleTrConn, responProce, semiCheckDefect, sUserInfo); // 保存失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } } #endregion } } #endregion } else if (entity.SemiCheckType == "1") //返工 { #region 1.从在产回收站中把数据恢复到在产表中。 string sqlInsert = @"insert into TP_PM_InProduction ( BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, CreateUserID, UpdateUserID, SpecialRepairflag, FlowProcedureID, FlowProcedureTime, ProcedureID, ProcedureTime, ProductionDataID, logoid, IsReworkFlag, SemiCheckID ) select BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, null, null, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, :CreateUserID, :UpdateUserID, SpecialRepairflag, FlowProcedureID, FlowProcedureTime, FlowProcedureID, ProcedureTime, ProductionDataID, logoid, 1, :SemiCheckID from TP_PM_InProductionTrash where barcode=:barcode "; OracleParameter[] oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":SemiCheckID",entity.SemiCheckID), new OracleParameter(":CreateUserID",sUserInfo.UserID), new OracleParameter(":UpdateUserID",sUserInfo.UserID), }; int result = oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters); #endregion #region 2.废弃产品表中对应的总单数据和明细数据valueflag='0'。 string sqlString = "select max(sp.scrapproductid) scrapproductid\n" + " from TP_PM_ScrapProduct sp\n" + " where sp.barcode = :barcode\n" + " and sp.auditstatus = 1\n" + " and sp.valueflag = '1'\n" + " and sp.scraptype = '2'"; spParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), }; string scrapproductid = oracleTrConn.GetSqlResultToStr(sqlString, spParameters); sqlString = @"update TP_PM_ScrapProduct set valueflag='0', updateuserid=:updateuserid, backouttime=sysdate where scrapproductid=:scrapproductid"; spParameters = new OracleParameter[] { new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":scrapproductid",scrapproductid), }; spResult = oracleTrConn.ExecuteNonQuery(sqlString, spParameters); sqlString = @"update TP_PM_ResponProcedure set valueflag='0', updateuserid=:updateuserid where scrapproductid=:scrapproductid"; //oracleParameters = new OracleParameter[] { // new OracleParameter(":barcode",entity.BarCode), //}; spResult += oracleTrConn.ExecuteNonQuery(sqlString, spParameters); //sql = @"update TP_PM_ScrapProduct set valueflag='0' where barcode=:barcode"; //oracleParameters = new OracleParameter[] { // new OracleParameter(":barcode",entity.BarCode), //}; //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); //sql = @"update TP_PM_ResponProcedure set valueflag='0' where barcode=:barcode"; //oracleParameters = new OracleParameter[] { // new OracleParameter(":barcode",entity.BarCode), //}; //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); ////sql = @"update TP_PM_ScrapResponsible set valueflag='0' where barcode=:barcode"; ////oracleParameters = new OracleParameter[] { //// new OracleParameter(":barcode",entity.BarCode), ////}; ////result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); #endregion #region 3.删除在产产品数据 sql = "delete from TP_PM_InProductionTrash where barcode=:barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), }; result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); #endregion #region 4.更新半检数据产品分级 sql = "update TP_PM_SemiCheck set GoodsLevelID=null,GoodsLevelTypeID=null where SemiCheckID=:SemiCheckID"; oracleParameters = new OracleParameter[] { new OracleParameter(":SemiCheckID",idStr), }; result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); #endregion #region 存在缺陷 插入缺陷表 if (entity.SemiCheckDefects != null) { foreach (SemiCheckDefectEntity semiCheckDefect in entity.SemiCheckDefects) { #region 保存缺陷 semiCheckDefect.SemiCheckID = Convert.ToInt32(idStr); semiCheckDefect.ScrapResponFlag = string.IsNullOrEmpty(semiCheckDefect.ScrapResponFlag) ? "0" : semiCheckDefect.ScrapResponFlag; // 保存缺陷 errMsg = AddSemiCheckDefect(oracleTrConn, semiCheckDefect, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } } #endregion } else if (entity.SemiCheckType == "0") //正常 { #region 1.从在产回收站中把数据恢复到在产表中。 string sqlInsert = @"insert into TP_PM_InProduction ( BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, CreateUserID, UpdateUserID, SpecialRepairflag, FlowProcedureID, FlowProcedureTime, ProcedureID, ProcedureTime, ProductionDataID, logoid, IsReworkFlag, SemiCheckID ) select BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, null, null, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, :CreateUserID, :UpdateUserID, SpecialRepairflag, FlowProcedureID, FlowProcedureTime, FlowProcedureID, ProcedureTime, ProductionDataID, logoid, 0, null from TP_PM_InProductionTrash where barcode=:barcode "; OracleParameter[] oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":CreateUserID",sUserInfo.UserID), new OracleParameter(":UpdateUserID",sUserInfo.UserID), }; int result = oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters); #endregion #region 2.废弃产品表中对应的总单数据和明细数据valueflag='0'。 string sqlString = "select max(sp.scrapproductid) scrapproductid\n" + " from TP_PM_ScrapProduct sp\n" + " where sp.barcode = :barcode\n" + " and sp.auditstatus = 1\n" + " and sp.valueflag = '1'\n" + " and sp.scraptype = '2'"; spParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), }; string scrapproductid = oracleTrConn.GetSqlResultToStr(sqlString, spParameters); sqlString = @"update TP_PM_ScrapProduct set valueflag='0', updateuserid=:updateuserid, backouttime=sysdate where scrapproductid=:scrapproductid"; spParameters = new OracleParameter[] { new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":scrapproductid",scrapproductid), }; spResult = oracleTrConn.ExecuteNonQuery(sqlString, spParameters); sqlString = @"update TP_PM_ResponProcedure set valueflag='0', updateuserid=:updateuserid where scrapproductid=:scrapproductid"; //oracleParameters = new OracleParameter[] { // new OracleParameter(":barcode",entity.BarCode), //}; spResult += oracleTrConn.ExecuteNonQuery(sqlString, spParameters); //sql = @"update TP_PM_ScrapProduct set valueflag='0' where barcode=:barcode"; //oracleParameters = new OracleParameter[] { // new OracleParameter(":barcode",entity.BarCode), //}; //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); //sql = @"update TP_PM_ResponProcedure set valueflag='0' where barcode=:barcode"; //oracleParameters = new OracleParameter[] { // new OracleParameter(":barcode",entity.BarCode), //}; //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); ////sql = @"update TP_PM_ScrapResponsible set valueflag='0' where barcode=:barcode"; ////oracleParameters = new OracleParameter[] { //// new OracleParameter(":barcode",entity.BarCode), ////}; ////result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); #endregion #region 3.删除在产回收站产品数据 sql = "delete from TP_PM_InProductionTrash where barcode=:barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), }; result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); #endregion } #endregion } return errMsg; } catch (Exception ex) { throw ex; } } /// /// 校验条码有效(新建) /// /// 连接对象 /// 条码 /// 登录用户信息 /// string /// /// 王鑫 2016.06.27 新建 /// private static string CheckBarcodeByNew(IDBTransaction oracleTrConn, string barcode, SUserInfo sUserInfo ) { try { OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input), }; string sql = @" select InScrapFlag, KilnCarID, KilnCarName, IsReworkFlag, SemiCheckID from TP_PM_InProduction where barcode=:barcode "; DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras); if (dsResult != null && dsResult.Tables[0].Rows.Count > 0) { if (dsResult.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1") { return "条码[" + barcode + "]已经报损待审批"; } if (!string.IsNullOrEmpty(dsResult.Tables[0].Rows[0]["KilnCarID"].ToString())) { return "条码[" + barcode + "]已经在窑车[" + dsResult.Tables[0].Rows[0]["KilnCarName"].ToString() + "]"; ; } if (dsResult.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1") { return "条码[" + barcode + "]已经返工中"; } } else { return "条码[" + barcode + "]不在在产流程"; } return null; } catch (Exception ex) { throw ex; } } /// /// 校验条码有效(编辑返工) /// /// 连接对象 /// 条码 /// 登录用户信息 /// string /// /// 王鑫 2016.06.27 新建 /// private static string CheckBarcodeByEditRework(IDBTransaction oracleTrConn, string barcode, SUserInfo sUserInfo ) { try { OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input), }; string sql = @" select InScrapFlag, KilnCarID, KilnCarName, IsReworkFlag, SemiCheckID from TP_PM_InProduction where barcode=:barcode "; DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras); if (dsResult != null && dsResult.Tables[0].Rows.Count > 0) { if (dsResult.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1") { return "条码[" + barcode + "]已经报损待审批"; } if (!string.IsNullOrEmpty(dsResult.Tables[0].Rows[0]["KilnCarID"].ToString())) { return "条码[" + barcode + "]已经在窑车[" + dsResult.Tables[0].Rows[0]["KilnCarName"].ToString() + "]"; ; } if (dsResult.Tables[0].Rows[0]["IsReworkFlag"].ToString() != "1") { return "条码[" + barcode + "]不在返工中"; } } else { return "条码[" + barcode + "]不在在产流程"; } return null; } catch (Exception ex) { throw ex; } } /// /// 校验条码有效(编辑不合格) /// /// 连接对象 /// 条码 /// 登录用户信息 /// string /// /// 王鑫 2016.06.27 新建 /// private static string CheckBarcodeByEditNoPass(IDBTransaction oracleTrConn, string barcode, SUserInfo sUserInfo ) { try { OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input), }; string sql = @" select 1 from TP_PM_InProductionTrash where barcode=:barcode and GoodsLevelTypeID=13 "; DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras); if (dsResult != null && dsResult.Tables[0].Rows.Count == 0) { return "条码[" + barcode + "]不在在产回收站中"; } return null; } catch (Exception ex) { throw ex; } } /// /// 添加半成品检验数据 /// /// 连接对象 /// 账务日期 /// 生产数据 /// 用户基本信息 /// string /// /// 陈冰 2014.09.18 新建 /// private static string AddSemiCheckData(IDBTransaction oracleTrConn, SemiCheckEntity entity, SUserInfo sUserInfo) { #region SQL string sql = "insert into tp_pm_semicheck" + " (semicheckid," + " barcode," + " productionlineid," + " procedureid," + " proceduretime," + " proceduremodel," + " modeltype," + " organizationid," + " goodsid," + " goodscode," + " userid," + " usercode," + " productiondataid," + " logoid," + " ispublicbody," + " specialrepairflag," + " goodslevelid," + " goodsleveltypeid," + " groutingdailyid," + " groutingdailydetailid," + " groutinglineid," + " groutinglinecode," + " groutinglinename," + " gmouldtypeid," + " canmanytimes," + " groutinglinedetailid," + " groutingdate," + " groutingmouldcode," + " mouldcode," + " groutinguserid," + " groutingusercode," + " groutingnum," + " semichecktype," + " semicheckuserID," + " semicheckusercode," + " semichecktime," + " remarks," + " accountid," + " createuserid," + " updateuserid," + " reworkprocedureid," + " reworkprocedurecode," + " reworkuserid," + " reworkusercode" + ")" + " select" + " :semicheckid," + " TP_PM_InProduction.barcode," + " TP_PM_InProduction.productionlineid," + " TP_PM_InProduction.procedureid," + " TP_PM_InProduction.proceduretime," + " TP_PM_InProduction.proceduremodel," + " TP_PM_InProduction.modeltype," + " tp_pc_procedure.organizationid," + " TP_PM_InProduction.goodsid," + " TP_PM_InProduction.goodscode," + " TP_PM_InProduction.userid," + " tp_mst_user.usercode," + " TP_PM_InProduction.productiondataid," + " TP_PM_InProduction.logoid," + " TP_PM_InProduction.ispublicbody," + " TP_PM_InProduction.specialrepairflag," + " TP_PM_InProduction.goodslevelid," + " TP_PM_InProduction.goodsleveltypeid," + " TP_PM_InProduction.groutingdailyid," + " TP_PM_InProduction.groutingdailydetailid," + " TP_PM_InProduction.groutinglineid," + " TP_PM_InProduction.groutinglinecode," + " TP_PM_InProduction.groutinglinename," + " TP_PM_InProduction.gmouldtypeid," + " TP_PM_InProduction.canmanytimes," + " TP_PM_InProduction.groutinglinedetailid," + " TP_PM_InProduction.groutingdate," + " TP_PM_InProduction.groutingmouldcode," + " TP_PM_InProduction.mouldcode," + " TP_PM_InProduction.groutinguserid," + " TP_PM_InProduction.groutingusercode," + " TP_PM_InProduction.groutingnum," + " :semichecktype," + " :semicheckuserID," + " :semicheckusercode," + " sysdate," + " :remarks," + " :accountid," + " :createuserid," + " :updateuserid," + " :reworkprocedureid," + " :reworkprocedurecode," + " :reworkuserid," + " :reworkusercode" + " from TP_PM_InProduction left join tp_mst_user on TP_PM_InProduction.UserID=tp_mst_user.userid " + " left join tp_pc_procedure on TP_PM_InProduction.ProcedureID=tp_pc_procedure.ProcedureID " + " where TP_PM_InProduction.barcode=:barcode"; #endregion #region OracleParameter OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":semicheckid",entity.SemiCheckID), new OracleParameter(":semichecktype",entity.SemiCheckType), new OracleParameter(":semicheckuserID",entity.SemiCheckUserID), new OracleParameter(":semicheckusercode",entity.SemiCheckUserCode), new OracleParameter(":remarks",entity.Remarks), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":reworkprocedureid",entity.ReworkProcedureID), new OracleParameter(":reworkprocedurecode",entity.ReworkProcedureCode), new OracleParameter(":reworkuserid",entity.ReworkUserID), new OracleParameter(":reworkusercode",entity.ReworkUserCode), }; #endregion foreach (OracleParameter para in paras) { if (string.IsNullOrEmpty(para.Value + "")) { para.Value = DBNull.Value; } } int result = oracleTrConn.ExecuteNonQuery(sql, paras); // 失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 成功返回null return null; } /// /// 添加半成品检验数据(不合格) /// /// 连接对象 /// 账务日期 /// 生产数据 /// 用户基本信息 /// string /// /// 陈冰 2014.09.18 新建 /// private static string AddSemiCheckDataNoPass(IDBTransaction oracleTrConn, SemiCheckEntity entity, SUserInfo sUserInfo) { #region SQL string sql = "insert into tp_pm_semicheck" + " (semicheckid," + " barcode," + " productionlineid," + " procedureid," + " proceduretime," + " proceduremodel," + " modeltype," + " organizationid," + " goodsid," + " goodscode," + " userid," + " usercode," + " productiondataid," + " logoid," + " ispublicbody," + " specialrepairflag," + " goodslevelid," + " goodsleveltypeid," + " groutingdailyid," + " groutingdailydetailid," + " groutinglineid," + " groutinglinecode," + " groutinglinename," + " gmouldtypeid," + " canmanytimes," + " groutinglinedetailid," + " groutingdate," + " groutingmouldcode," + " mouldcode," + " groutinguserid," + " groutingusercode," + " groutingnum," + " semichecktype," + " semicheckuserID," + " semicheckusercode," + " semichecktime," + " remarks," + " accountid," + " createuserid," + " updateuserid," + " reworkprocedureid," + " reworkprocedurecode," + " reworkuserid," + " reworkusercode" + ")" + " select" + " :semicheckid," + " TP_PM_InProduction.barcode," + " TP_PM_InProduction.productionlineid," + " TP_PM_InProduction.procedureid," + " TP_PM_InProduction.proceduretime," + " TP_PM_InProduction.proceduremodel," + " TP_PM_InProduction.modeltype," + " tp_pc_procedure.organizationid," + " TP_PM_InProduction.goodsid," + " TP_PM_InProduction.goodscode," + " TP_PM_InProduction.userid," + " tp_mst_user.usercode," + " TP_PM_InProduction.productiondataid," + " TP_PM_InProduction.logoid," + " TP_PM_InProduction.ispublicbody," + " TP_PM_InProduction.specialrepairflag," + " (select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid)," + " 13," + " TP_PM_InProduction.groutingdailyid," + " TP_PM_InProduction.groutingdailydetailid," + " TP_PM_InProduction.groutinglineid," + " TP_PM_InProduction.groutinglinecode," + " TP_PM_InProduction.groutinglinename," + " TP_PM_InProduction.gmouldtypeid," + " TP_PM_InProduction.canmanytimes," + " TP_PM_InProduction.groutinglinedetailid," + " TP_PM_InProduction.groutingdate," + " TP_PM_InProduction.groutingmouldcode," + " TP_PM_InProduction.mouldcode," + " TP_PM_InProduction.groutinguserid," + " TP_PM_InProduction.groutingusercode," + " TP_PM_InProduction.groutingnum," + " :semichecktype," + " :semicheckuserID," + " :semicheckusercode," + " sysdate," + " :remarks," + " :accountid," + " :createuserid," + " :updateuserid," + " :reworkprocedureid," + " :reworkprocedurecode," + " :reworkuserid," + " :reworkusercode" + " from TP_PM_InProduction left join tp_mst_user on TP_PM_InProduction.UserID=tp_mst_user.userid " + " left join tp_pc_procedure on TP_PM_InProduction.ProcedureID=tp_pc_procedure.ProcedureID " + " where TP_PM_InProduction.barcode=:barcode"; #endregion #region OracleParameter OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":semicheckid",entity.SemiCheckID), new OracleParameter(":semichecktype",entity.SemiCheckType), new OracleParameter(":semicheckuserID",entity.SemiCheckUserID), new OracleParameter(":semicheckusercode",entity.SemiCheckUserCode), new OracleParameter(":remarks",entity.Remarks), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":reworkprocedureid",entity.ReworkProcedureID), new OracleParameter(":reworkprocedurecode",entity.ReworkProcedureCode), new OracleParameter(":reworkuserid",entity.ReworkUserID), new OracleParameter(":reworkusercode",entity.ReworkUserCode), }; #endregion foreach (OracleParameter para in paras) { if (string.IsNullOrEmpty(para.Value + "")) { para.Value = DBNull.Value; } } int result = oracleTrConn.ExecuteNonQuery(sql, paras); // 失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 成功返回null return null; } /// /// 添加半成品检验数据 /// /// 连接对象 /// 账务日期 /// 生产数据 /// 用户基本信息 /// string /// /// 陈冰 2014.09.18 新建 /// private static string AddSemiCheckDataTrash(IDBTransaction oracleTrConn, SemiCheckEntity entity, SUserInfo sUserInfo) { #region SQL string sql = "insert into tp_pm_semicheck" + " (semicheckid," + " barcode," + " productionlineid," + " procedureid," + " proceduretime," + " proceduremodel," + " modeltype," + " organizationid," + " goodsid," + " goodscode," + " userid," + " usercode," + " productiondataid," + " logoid," + " ispublicbody," + " specialrepairflag," + " goodslevelid," + " goodsleveltypeid," + " groutingdailyid," + " groutingdailydetailid," + " groutinglineid," + " groutinglinecode," + " groutinglinename," + " gmouldtypeid," + " canmanytimes," + " groutinglinedetailid," + " groutingdate," + " groutingmouldcode," + " mouldcode," + " groutinguserid," + " groutingusercode," + " groutingnum," + " semichecktype," + " semicheckuserID," + " semicheckusercode," + " semichecktime," + " remarks," + " accountid," + " createuserid," + " updateuserid," + " reworkprocedureid," + " reworkprocedurecode," + " reworkuserid," + " reworkusercode" + ")" + " select" + " :semicheckid," + " trash.barcode," + " trash.productionlineid," + " trash.procedureid," + " trash.proceduretime," + " trash.proceduremodel," + " trash.modeltype," + " tp_pc_procedure.organizationid," + " trash.goodsid," + " trash.goodscode," + " trash.userid," + " tp_mst_user.usercode," + " trash.productiondataid," + " trash.logoid," + " trash.ispublicbody," + " trash.specialrepairflag," + " trash.goodslevelid," + " trash.goodsleveltypeid," + " trash.groutingdailyid," + " trash.groutingdailydetailid," + " trash.groutinglineid," + " trash.groutinglinecode," + " trash.groutinglinename," + " trash.gmouldtypeid," + " trash.canmanytimes," + " trash.groutinglinedetailid," + " trash.groutingdate," + " trash.groutingmouldcode," + " trash.mouldcode," + " trash.groutinguserid," + " trash.groutingusercode," + " trash.groutingnum," + " :semichecktype," + " :semicheckuserID," + " :semicheckusercode," + " sysdate," + " :remarks," + " :accountid," + " :createuserid," + " :updateuserid," + " :reworkprocedureid," + " :reworkprocedurecode," + " :reworkuserid," + " :reworkusercode" + " from TP_PM_InProductionTrash trash left join tp_mst_user on trash.UserID=tp_mst_user.userid " + " left join tp_pc_procedure on trash.ProcedureID=tp_pc_procedure.ProcedureID " + " where trash.barcode=:barcode"; #endregion #region OracleParameter OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":semicheckid",entity.SemiCheckID), new OracleParameter(":semichecktype",entity.SemiCheckType), new OracleParameter(":semicheckuserID",entity.SemiCheckUserID), new OracleParameter(":semicheckusercode",entity.SemiCheckUserCode), new OracleParameter(":remarks",entity.Remarks), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":reworkprocedureid",entity.ReworkProcedureID), new OracleParameter(":reworkprocedurecode",entity.ReworkProcedureCode), new OracleParameter(":reworkuserid",entity.ReworkUserID), new OracleParameter(":reworkusercode",entity.ReworkUserCode), }; #endregion foreach (OracleParameter para in paras) { if (string.IsNullOrEmpty(para.Value + "")) { para.Value = DBNull.Value; } } int result = oracleTrConn.ExecuteNonQuery(sql, paras); // 失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 成功返回null return null; } /// /// 添加半成品检验数据 /// /// 连接对象 /// 账务日期 /// 生产数据 /// 用户基本信息 /// string /// /// 陈冰 2014.09.18 新建 /// private static string SetSemiCheckDataValueFlag(IDBTransaction oracleTrConn, SemiCheckEntity entity, SUserInfo sUserInfo) { #region SQL string sql = @"update TP_PM_SemiCheck set BackOutUserID=:BackOutUserID, BackOutUserCode=:BackOutUserCode, BackOutFlag=1, BackOutTime=sysdate, ValueFlag='0', updateuserid=:updateuserid where semicheckid=:semicheckid"; #region OracleParameter OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":semicheckid",entity.SemiCheckID), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":BackOutUserID",sUserInfo.UserID), new OracleParameter(":BackOutUserCode",sUserInfo.UserCode), }; #endregion int result = oracleTrConn.ExecuteNonQuery(sql, paras); string sql2 = @"update TP_PM_SemiCheckDefect set ValueFlag='0', updateuserid=:updateuserid where semicheckid=:semicheckid"; string sql3 = @"update TP_PM_SCDefectResponsible set ValueFlag='0', updateuserid=:updateuserid where semicheckid=:semicheckid"; #endregion #region OracleParameter paras = new OracleParameter[] { new OracleParameter(":semicheckid",entity.SemiCheckID), new OracleParameter(":updateuserid",sUserInfo.UserID), }; #endregion foreach (OracleParameter para in paras) { if (string.IsNullOrEmpty(para.Value + "")) { para.Value = DBNull.Value; } } result += oracleTrConn.ExecuteNonQuery(sql2, paras); result += oracleTrConn.ExecuteNonQuery(sql3, paras); // 失败 if (result == Constant.INT_IS_ZERO) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } // 成功返回null return null; } /// /// 保存半检缺陷 /// /// 连接对象 /// 缺陷数据 /// 用户基本信息 /// string private static string AddSemiCheckDefect(IDBTransaction oracleTrConn, SemiCheckDefectEntity semiCheckDefect, SUserInfo sUserInfo) { // 查询新插入的半检缺陷ID string sql = "select SEQ_PM_SemiCheckDefect_ID.nextval from dual"; string idStr = oracleTrConn.GetSqlResultToStr(sql); int semiCheckDefectID = 0; if (!string.IsNullOrEmpty(idStr)) { semiCheckDefectID = int.Parse(idStr); } else { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } #region SQL sql = "insert into TP_PM_SemiCheckDefect" + " (semicheckdefectid," + " semicheckid," + " defectid," + " defectcode," + " defectname," + " defectpositionid," + " defectpositioncode," + " defectpositionname," + " scrapResponFlag," + " defectproductiondataid," + " defectprocedureid," + " defectuserid," + " defectusercode," + " remarks," + " accountid," + " createuserid," + " updateuserid)" + " values" + " (" + " :semicheckdefectid," + " :semicheckid," + " :defectid," + " :defectcode," + " :defectname," + " :defectpositionid," + " :defectpositioncode," + " :defectpositionname," + " :scrapResponFlag," + " :defectproductiondataid," + " :defectprocedureid," + " :defectuserid," + " :defectusercode," + " :remarks," + " :accountid," + " :createuserid," + " :updateuserid)"; #endregion #region 参数 OracleParameter[] oracleParameters = new OracleParameter[] { new OracleParameter(":semicheckdefectid",semiCheckDefectID), new OracleParameter(":semicheckid",semiCheckDefect.SemiCheckID), new OracleParameter(":defectid",semiCheckDefect.DefectID), new OracleParameter(":defectcode",semiCheckDefect.DefectCode), new OracleParameter(":defectname",semiCheckDefect.DefectName), new OracleParameter(":defectpositionid",semiCheckDefect.DefectPositionID), new OracleParameter(":defectpositioncode",semiCheckDefect.DefectPositionCode), new OracleParameter(":defectpositionname",semiCheckDefect.DefectPositionName), new OracleParameter(":scrapResponFlag",semiCheckDefect.ScrapResponFlag), new OracleParameter(":defectproductiondataid",semiCheckDefect.DefectProductionDataID), new OracleParameter(":defectprocedureid",semiCheckDefect.DefectProcedureID), new OracleParameter(":defectuserid",semiCheckDefect.DefectUserID), new OracleParameter(":defectusercode",semiCheckDefect.DefectUserCode), new OracleParameter(":remarks",semiCheckDefect.Remarks), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), }; #endregion int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } #region 插入生产缺陷责任者 if (semiCheckDefect.DefectResponsibles != null) { foreach (SemiCheckResponsibleEntity DefectResponsible in semiCheckDefect.DefectResponsibles) { #region SQL sql = "insert into TP_PM_SCDefectResponsible" + " (semicheckdefectid," + " staffid," + " semicheckid," + " userid," + " usercode," + " Ujobsid," + " SJobsID," + " staffstatus," + " accountid," + " createuserid," + " updateuserid)" + " values" + " (:semicheckdefectid," + " :staffid," + " :semicheckid," + " :userid," + " :usercode," + " :ujobsid," + " :sjobsid," + " :staffstatus," + " :accountid," + " :createuserid," + " :updateuserid)"; #endregion #region 参数 oracleParameters = new OracleParameter[] { new OracleParameter(":semicheckdefectid",semiCheckDefectID), new OracleParameter(":staffid",DefectResponsible.StaffID), new OracleParameter(":semicheckid",semiCheckDefect.SemiCheckID), new OracleParameter(":userid",DefectResponsible.UserID), new OracleParameter(":usercode",DefectResponsible.UserCode), new OracleParameter(":ujobsid",DefectResponsible.UJobsID), new OracleParameter(":sjobsid",DefectResponsible.SJobsID), new OracleParameter(":staffstatus",DefectResponsible.StaffStatus), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), }; #endregion result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } } } #endregion return null; } /// /// 添加责任工序 /// /// 连接对象 /// 责任工序 /// 缺陷数据 /// 用户基本信息 /// string private static string AddSemiCheckResponProcedure(IDBTransaction oracleTrConn, ResponProcedureEntity responProce, SemiCheckDefectEntity productionDefect, SUserInfo sUserInfo) { OracleParameter[] oracleParameters = null; string sql = null; int result = 0; // 查询新插入ID if (responProce.ProcedureID != null) { sql = "select SEQ_PM_ResponProcedure_ID.nextval from dual"; string idStr = oracleTrConn.GetSqlResultToStr(sql); if (!string.IsNullOrEmpty(idStr)) { responProce.ResponProcedureID = int.Parse(idStr); } else { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } #region SQL sql = "insert into tp_pm_responprocedure" + " (ResponProcedureID," + " scrapproductid," + " barcode," + " productiondataid," + " productionlineid," + " productionlinecode," + " productionlinename," + " procedureid," + " procedurecode," + " procedurename," + " userid," + " usercode," + " username," + " remarks," + " accountid," + " createuserid," + " updateuserid)" + " values" + " (" + " :ResponProcedureID," + " :scrapproductid," + " :barcode," + " :productiondataid," + " :productionlineid," + " :productionlinecode," + " :productionlinename," + " :procedureid," + " :procedurecode," + " :procedurename," + " :userid," + " :usercode," + " :username," + " :remarks," + " :accountid," + " :createuserid," + " :updateuserid)"; #endregion #region 参数 oracleParameters = new OracleParameter[] { new OracleParameter(":ResponProcedureID",responProce.ResponProcedureID), new OracleParameter(":scrapproductid",responProce.ScrapProductID), new OracleParameter(":barcode",responProce.BarCode), new OracleParameter(":productiondataid",responProce.ProductionDataID), new OracleParameter(":productionlineid",responProce.ProductionLineID), new OracleParameter(":productionlinecode",responProce.ProductionLineCode), new OracleParameter(":productionlinename",responProce.ProductionLineName), new OracleParameter(":procedureid",responProce.ProcedureID), new OracleParameter(":procedurecode",responProce.ProcedureCode), new OracleParameter(":procedurename",responProce.ProcedureName), new OracleParameter(":userid",responProce.UserID), new OracleParameter(":usercode",responProce.UserCode), new OracleParameter(":username",responProce.UserName), new OracleParameter(":remarks",responProce.Remarks), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), }; #endregion result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } //// 查询新插入ID //sql = "select SEQ_PM_ResponProcedure_ID.Currval from dual"; //string idStr = oracleTrConn.GetSqlResultToStr(sql); //if (!string.IsNullOrEmpty(idStr)) //{ // responProce.ResponProcedureID = int.Parse(idStr); //} //else //{ // return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); //} } #region 插入责任人 foreach (SemiCheckResponsibleEntity defectResponsible in productionDefect.DefectResponsibles) { #region SQL sql = "insert into tp_pm_scrapresponsible" + " (barcode," + " scrapproductid," + " staffid," + " userid," + " usercode," + " ujobsid," + " sjobsid," + " staffstatus," + " accountid," + " createuserid," + " updateuserid," + " responprocedureid," + " respontype)" + " values" + " (:barcode," + " :scrapproductid," + " :staffid," + " :userid," + " :usercode," + " :ujobsid," + " :sjobsid," + " :staffstatus," + " :accountid," + " :createuserid," + " :updateuserid," + " :responprocedureid," + " :respontype)"; #endregion #region 参数 oracleParameters = new OracleParameter[] { new OracleParameter(":scrapproductid",responProce.ScrapProductID), new OracleParameter(":barcode",responProce.BarCode), new OracleParameter(":staffid",defectResponsible.StaffID), new OracleParameter(":userid",defectResponsible.UserID), new OracleParameter(":usercode",defectResponsible.UserCode), new OracleParameter(":ujobsid",defectResponsible.UJobsID), new OracleParameter(":sjobsid",defectResponsible.SJobsID), new OracleParameter(":staffstatus",defectResponsible.StaffStatus), new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":responprocedureid",responProce.ResponProcedureID), new OracleParameter(":respontype", (responProce.ResponProcedureID == null? (int)Constant.ScrapResponType.Person:(int)Constant.ScrapResponType.Procedure)), }; #endregion result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); // 保存失败 if (result != Constant.INT_IS_ONE) { return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } } #endregion return null; } #region 复检 /// /// 复检数据 /// /// 数据连接对象 /// 半检实体类 /// 用户基本信息 /// string /// /// 王鑫 2016.06.28 新建 /// private static string AddReSemiCheck(IDBTransaction oracleTrConn, SemiCheckEntity entity, SUserInfo sUserInfo) { try { // 获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); string errMsg = string.Empty; #region 校验条码有效性 errMsg = CheckBarcodeByEditRework(oracleTrConn, entity.BarCode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion //------------------------------ #region 条码是不合格 删除在产产品数据 if (entity.ReSemiCheckType == "2") //编辑时不合格 { #region 修改半检登记的复检状态=2不合格(返)、复检工号=当前工号、复检时间=sysdate。 string sqlUpdate = @"update TP_PM_SemiCheck set ReSemiCheckType='2' ,ReSemiCheckUserID=:ReSemiCheckUserID, ReSemiCheckUserCode=:ReSemiCheckUserCode,ReSemiCheckTime=sysdate,updateuserid=:updateuserid where SemiCheckID=:SemiCheckID"; OracleParameter[] oracleParameters = new OracleParameter[] { new OracleParameter(":ReSemiCheckUserID",sUserInfo.UserID), new OracleParameter(":ReSemiCheckUserCode",sUserInfo.UserCode), new OracleParameter(":SemiCheckID",entity.SemiCheckID), new OracleParameter(":updateuserid",sUserInfo.UserID), }; int result = oracleTrConn.ExecuteNonQuery(sqlUpdate, oracleParameters); // 保存失败 if (result != Constant.INT_IS_ONE) { errMsg = string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } #endregion #region 条码有缺陷 #region 是次品 添加废弃产品 string ResponProcedureidStr = ""; if (entity.ReSemiCheckType == "2") //新建时不合格,直接报损 { #region 添加废弃产品 ScrapProductEntity scrapProduct = new ScrapProductEntity(); #region 属性赋值 scrapProduct.BarCode = entity.BarCode; scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode(); scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode(); scrapProduct.ScrapDate = accountDate; scrapProduct.Rreason = Constant.SCRAPTYPE_NOPASSREWORK; scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode(); scrapProduct.Auditor = sUserInfo.UserID; scrapProduct.AuditlDate = accountDate; scrapProduct.AccountDate = accountDate; sqlUpdate = "select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=14 and accountid=" + sUserInfo.AccountID; DataSet ds = oracleTrConn.GetSqlResultToDs(sqlUpdate); if (ds != null && ds.Tables[0].Rows.Count > 0) { scrapProduct.GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]); } scrapProduct.GoodsLevelTypeID = 14; //scrapProduct.GoodsLevelID = entity.GoodsLevelID; //scrapProduct.GoodsLevelTypeID = entity.GoodsLevelTypeID; scrapProduct.IsPublicBody = IsPubilcByBarCode(oracleTrConn, entity.BarCode); // 查询新插入的废弃ID string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.nextval from dual"; ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql); scrapProduct.ScrapProductID = Convert.ToInt32(ResponProcedureidStr); scrapProduct.ScrapType = 3; #endregion // 保存报废 errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo); // 保存失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } #endregion // 存在缺陷 插入缺陷表 if (entity.SemiCheckDefects != null) { foreach (SemiCheckDefectEntity semiCheckDefect in entity.SemiCheckDefects) { #region 保存缺陷 //semiCheckDefect.SemiCheckID = Convert.ToInt32(semiCheckDefect.SemiCheckID); //semiCheckDefect.ScrapResponFlag // = string.IsNullOrEmpty(semiCheckDefect.ScrapResponFlag) ? "0" : semiCheckDefect.ScrapResponFlag; //// 保存缺陷 //errMsg = AddSemiCheckDefect(oracleTrConn, semiCheckDefect, sUserInfo); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} #endregion #region 是不合格 添加废弃责任工序 if (entity.ReSemiCheckType == "2") { //if (semiCheckDefect.DefectProcedureID != null) { #region 添加责任工序 ResponProcedureEntity responProce = new ResponProcedureEntity(); #region 属性赋值 responProce.BarCode = entity.BarCode; // 新建-不合格 获取生产线及生产数据ID sqlUpdate = "select ProductionLineID,ProductionLineCode,ProductionLineName,ProductionDataID from TP_PM_InProduction where barcode=:barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), }; DataSet ds = oracleTrConn.GetSqlResultToDs(sqlUpdate, oracleParameters); if (ds != null && ds.Tables[0].Rows.Count > 0) { responProce.ProductionDataID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionDataID"]); responProce.ProductionLineID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionLineID"]); responProce.ProductionLineCode = ds.Tables[0].Rows[0]["ProductionLineCode"].ToString(); responProce.ProductionLineName = ds.Tables[0].Rows[0]["ProductionLineName"].ToString(); } //responProce.ProductionDataID = semiCheckDefect.ProductionDataID; //responProce.ProductionLineID = semiCheckDefect.ProductionLineID; //responProce.ProductionLineCode = semiCheckDefect.ProductionLineCode; //responProce.ProductionLineName = semiCheckDefect.ProductionLineName; responProce.ProcedureID = semiCheckDefect.DefectProcedureID; responProce.ProcedureCode = semiCheckDefect.DefectProcedureCode; responProce.ProcedureName = semiCheckDefect.DefectProcedureName; responProce.UserID = semiCheckDefect.DefectUserID; responProce.UserCode = semiCheckDefect.DefectUserCode; responProce.UserName = semiCheckDefect.DefectUserName; responProce.Remarks = semiCheckDefect.Remarks; responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr); #endregion // 保存责任工序 errMsg = AddSemiCheckResponProcedure(oracleTrConn, responProce, semiCheckDefect, sUserInfo); // 保存失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion } } #endregion } } #endregion // 1.在产表产品设置产品等级【14不合格返】。 string sql = @"update TP_PM_InProduction set GoodsLevelID= ( select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=14 and accountid=:accountid ),GoodsLevelTypeID=14,updateuserid=:updateuserid where barcode=:barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":accountid", sUserInfo.AccountID), // new OracleParameter(":updateuserid",scrapProduct.GoodsLevelTypeID), new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":updateuserid",sUserInfo.UserID), }; result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); // 2.将在产数据保存到在产回收站表中(产品等级【14不合格返】)。 string sqlInsert = @"insert into TP_PM_InProductionTrash ( BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, CreateUserID, UpdateUserID, SpecialRepairflag, FlowProcedureID, FlowProcedureTime, ProcedureID, ProcedureTime, ProductionDataID, logoid, SemiCheckID ) select BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, --GoodsLevelID, --GoodsLevelTypeID, ( select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=14 and accountid=:accountid ),14, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, :CreateUserID, :UpdateUserID, SpecialRepairflag, FlowProcedureID, FlowProcedureTime, FlowProcedureID, ProcedureTime, ProductionDataID, logoid, SemiCheckID from TP_PM_InProduction where barcode=:barcode "; oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":CreateUserID",sUserInfo.UserID), new OracleParameter(":UpdateUserID",sUserInfo.UserID), new OracleParameter(":accountid", sUserInfo.AccountID), }; result += oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters); // 删除在产数据 sql = "delete tp_pm_inproduction where barcode = :barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), }; result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); } else if (entity.ReSemiCheckType == "1") //正常 { #region 修改半检登记的复检状态=1合格(返)、复检工号=当前工号、复检时间=sysdate。 string sqlUpdate = @"update TP_PM_SemiCheck set ReSemiCheckType='1' ,ReSemiCheckUserID=:ReSemiCheckUserID, ReSemiCheckUserCode=:ReSemiCheckUserCode,ReSemiCheckTime=sysdate,updateuserid=:updateuserid where SemiCheckID=:SemiCheckID"; OracleParameter[] oracleParameters = new OracleParameter[] { new OracleParameter(":ReSemiCheckUserID",sUserInfo.UserID), new OracleParameter(":ReSemiCheckUserCode",sUserInfo.UserCode), new OracleParameter(":SemiCheckID",entity.SemiCheckID), new OracleParameter(":updateuserid",sUserInfo.UserID), }; int result = oracleTrConn.ExecuteNonQuery(sqlUpdate, oracleParameters); // 保存失败 if (result != Constant.INT_IS_ONE) { errMsg = string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } #endregion #region 3.修改在产产品数据,在产表产品设置非返工状态(IsReworkFlag = '0'),半检登记ID=null(半检登记ID不变)。 string sql = "update tp_pm_inproduction set IsReworkFlag='0',UpdateUserID=:UpdateUserID where barcode = :barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":UpdateUserID",sUserInfo.UserID), }; result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); #endregion } #endregion //------------------------------ return errMsg; } catch (Exception ex) { throw ex; } } #endregion #region 撤销复检 /// /// 撤销复检数据 /// /// 数据连接对象 /// 半检实体类 /// 用户基本信息 /// string /// /// 王鑫 2016.06.28 新建 /// private static string AddCancelSemiCheck(IDBTransaction oracleTrConn, SemiCheckEntity entity, SUserInfo sUserInfo) { try { // 获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); string errMsg = string.Empty; string sql = null; #region 校验条码有效性 if (entity.ReSemiCheckType == "1") //撤销合格 { errMsg = CheckBarcodeByCancelReSemiCheckPass(oracleTrConn, entity.BarCode, sUserInfo); } else if (entity.ReSemiCheckType == "2") //撤销不合格 { errMsg = CheckBarcodeByCancelReSemiCheckNoPass(oracleTrConn, entity.BarCode, sUserInfo); } if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } #endregion if (entity.ReSemiCheckType == "1") //撤销合格 { #region 在产表产品设置返工状态(IsReworkFlag = '1')。 sql = "update tp_pm_inproduction set IsReworkFlag='1',UpdateUserID=:UpdateUserID where barcode = :barcode"; OracleParameter[] oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":UpdateUserID",sUserInfo.UserID), }; int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); #endregion #region .半检登记的复检状态=0未复检,复检工号=null,复检时间=null。 // 复检撤销不需要记录撤销标识 - chenxy string sqlUpdate = @"update TP_PM_SemiCheck set ReSemiCheckType='0' ,ReSemiCheckUserID=null, ReSemiCheckUserCode=null,ReSemiCheckTime=null,updateuserid=:updateuserid --,BackOutFlag=1,BackOutTime=sysdate,BackOutUserID=:BackOutUserID,BackOutUserCode=:BackOutUserCode where SemiCheckID=:SemiCheckID"; oracleParameters = new OracleParameter[] { new OracleParameter(":SemiCheckID",entity.SemiCheckID), new OracleParameter(":updateuserid",sUserInfo.UserID), //new OracleParameter(":BackOutUserID",sUserInfo.UserID), //new OracleParameter(":BackOutUserCode",sUserInfo.UserCode), }; result = oracleTrConn.ExecuteNonQuery(sqlUpdate, oracleParameters); // 保存失败 if (result != Constant.INT_IS_ONE) { errMsg = string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } #endregion } else if (entity.ReSemiCheckType == "2") //撤销不合格 { #region 从在产回收站中把数据恢复到在产表中。 string sqlInsert = @"insert into TP_PM_InProduction ( BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, CreateUserID, UpdateUserID, SpecialRepairflag, FlowProcedureID, FlowProcedureTime, ProcedureID, ProcedureTime, ProductionDataID, logoid, SemiCheckID ) select BarCode, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureModel, ModelType, DefectFlag, ReworkProcedureID, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, GoodsID, GoodsCode, GoodsName, UserID, GroutingDailyID, GroutingDailyDetailID, GroutingDate, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, AccountID, ValueFlag, :CreateUserID, :UpdateUserID, SpecialRepairflag, FlowProcedureID, FlowProcedureTime, FlowProcedureID, ProcedureTime, ProductionDataID, logoid, SemiCheckID from TP_PM_InProductionTrash where barcode=:barcode "; OracleParameter[] oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":CreateUserID",sUserInfo.UserID), new OracleParameter(":UpdateUserID",sUserInfo.UserID), }; int result = oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters); #endregion #region 1.废弃产品表中对应的总单数据和明细数据valueflag='0'。 OracleParameter[] spParameters = null; int spResult = 0; string sqlString = "select max(sp.scrapproductid) scrapproductid\n" + " from TP_PM_ScrapProduct sp\n" + " where sp.barcode = :barcode\n" + " and sp.auditstatus = 1\n" + " and sp.valueflag = '1'\n" + " and sp.scraptype = '3'"; spParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), }; string scrapproductid = oracleTrConn.GetSqlResultToStr(sqlString, spParameters); sqlString = @"update TP_PM_ScrapProduct set valueflag='0', updateuserid=:updateuserid, backouttime=sysdate where scrapproductid=:scrapproductid"; spParameters = new OracleParameter[] { new OracleParameter(":updateuserid",sUserInfo.UserID), new OracleParameter(":scrapproductid",scrapproductid), }; spResult = oracleTrConn.ExecuteNonQuery(sqlString, spParameters); sqlString = @"update TP_PM_ResponProcedure set valueflag='0', updateuserid=:updateuserid where scrapproductid=:scrapproductid"; //oracleParameters = new OracleParameter[] { // new OracleParameter(":barcode",entity.BarCode), //}; spResult += oracleTrConn.ExecuteNonQuery(sqlString, spParameters); //string sql = @"update TP_PM_ScrapProduct set valueflag='0' where barcode=:barcode"; //oracleParameters = new OracleParameter[] { // new OracleParameter(":barcode",entity.BarCode), // }; //result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); //sql = @"update TP_PM_ResponProcedure set valueflag='0' where barcode=:barcode"; //oracleParameters = new OracleParameter[] { // new OracleParameter(":barcode",entity.BarCode), // }; //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); ////sql = @"update TP_PM_ScrapResponsible set valueflag='0' where barcode=:barcode"; ////oracleParameters = new OracleParameter[] { //// new OracleParameter(":barcode",entity.BarCode), //// }; ////result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); #endregion #region 删除在产回收站数据 sql = "delete TP_PM_InProductionTrash where barcode = :barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), }; result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); #endregion #region .在产表产品设置返工状态(IsReworkFlag = '1')。 sql = "update tp_pm_inproduction set IsReworkFlag='1',UpdateUserID=:UpdateUserID where barcode = :barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":UpdateUserID",sUserInfo.UserID), }; result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters); #endregion #region 6.半检登记的复检状态=0未复检,复检工号=null,复检时间=null。 // 复检撤销不需要记录撤销标识 - chenxy string sqlUpdate = @"update TP_PM_SemiCheck set ReSemiCheckType='0' ,ReSemiCheckUserID=null, ReSemiCheckUserCode=null,ReSemiCheckTime=null,updateuserid=:updateuserid --,BackOutFlag=1,BackOutTime=sysdate,BackOutUserID=:BackOutUserID,BackOutUserCode=:BackOutUserCode where SemiCheckID=:SemiCheckID"; oracleParameters = new OracleParameter[] { //new OracleParameter(":ReSemiCheckUserID",entity.ReSemiCheckUserID), //new OracleParameter(":ReSemiCheckUserCode",entity.ReSemiCheckUserCode), new OracleParameter(":SemiCheckID",entity.SemiCheckID), new OracleParameter(":updateuserid",sUserInfo.UserID), //new OracleParameter(":BackOutUserID",sUserInfo.UserID), //new OracleParameter(":BackOutUserCode",sUserInfo.UserCode), }; result = oracleTrConn.ExecuteNonQuery(sqlUpdate, oracleParameters); // 保存失败 if (result != Constant.INT_IS_ONE) { errMsg = string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } #endregion } return errMsg; } catch (Exception ex) { throw ex; } } #endregion /// /// 校验条码有效(撤销复检-不合格) /// /// 连接对象 /// 条码 /// 登录用户信息 /// string /// /// 王鑫 2016.06.28 新建 /// private static string CheckBarcodeByCancelReSemiCheckNoPass(IDBTransaction oracleTrConn, string barcode, SUserInfo sUserInfo ) { try { OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input), }; string sql = @" select 1 from TP_PM_InProductionTrash where barcode=:barcode and GoodsLevelTypeID=14 and SemiCheckID is not null "; DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras); if (dsResult != null && dsResult.Tables[0].Rows.Count == 0) { return "条码[" + barcode + "]不在在产回收站中"; } return null; } catch (Exception ex) { throw ex; } } /// /// 校验条码有效(撤销复检-合格) /// /// 连接对象 /// 条码 /// 登录用户信息 /// string /// /// 王鑫 2016.06.28 新建 /// private static string CheckBarcodeByCancelReSemiCheckPass(IDBTransaction oracleTrConn, string barcode, SUserInfo sUserInfo ) { try { OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input), }; string sql = @" select InScrapFlag, KilnCarID, KilnCarName, IsReworkFlag, SemiCheckID from TP_PM_InProduction where barcode=:barcode "; DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras); if (dsResult != null && dsResult.Tables[0].Rows.Count > 0) { if (dsResult.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1") { return "条码[" + barcode + "]已经报损待审批"; } if (!string.IsNullOrEmpty(dsResult.Tables[0].Rows[0]["KilnCarID"].ToString())) { return "条码[" + barcode + "]已经在窑车[" + dsResult.Tables[0].Rows[0]["KilnCarName"].ToString() + "]"; ; } if (dsResult.Tables[0].Rows[0]["IsReworkFlag"].ToString() != "0") { return "条码[" + barcode + "]是半检返工状态"; } if (string.IsNullOrEmpty(dsResult.Tables[0].Rows[0]["SemiCheckID"].ToString())) { return "条码[" + barcode + "]已经做过其他操作,不能撤销"; } } else { return "条码[" + barcode + "]不在在产流程"; } return null; } catch (Exception ex) { throw ex; } } #region 生产订单 wangx 2017-2-7 /// /// 保存订单 /// /// /// /// public static ServiceResultEntity SaveOrder(OrderEntity order, SUserInfo sUserInfo) { ServiceResultEntity entity = new ServiceResultEntity(); int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { string sql = string.Empty; OracleParameter[] Paras = null; DataSet ds = null; #region 查询订单号是否有重复 sql = "select OrderID from TP_PM_Order where OrderNo=:OrderNo and AccountID=:AccountID"; Paras = new OracleParameter[] { new OracleParameter(":OrderNo",OracleDbType.Varchar2, order.OrderNo,ParameterDirection.Input), new OracleParameter(":AccountID",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input) }; ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds != null && ds.Tables[0].Rows.Count > 0) { if (order.OrderID == 0 || (order.OrderID != Convert.ToInt32(ds.Tables[0].Rows[0]["OrderID"]))) { //重复订单号 returnRows = -1; oracleTrConn.Rollback(); oracleTrConn.Disconnect(); entity.Result = returnRows; entity.Message = "系统存在相同的生产订单号!"; return entity; } } #endregion #region 添加、编辑生产订单 if (order.OrderID == 0) { string sqlText = "SELECT SEQ_PM_Order_OrderID.NEXTVAL FROM dual"; int newOrderID = int.Parse(oracleTrConn.GetSqlResultToStr(sqlText)); sql = @"Insert into TP_PM_Order ( OrderID, OrderNo, OrderDate, Remarks, AccountID, ValueFlag, CreateTime, CreateUserID, UpdateTime, UpdateUserID ) Values ( :OrderID, :OrderNo, :OrderDate, :Remarks, :AccountID, :ValueFlag, sysdate, :CreateUserID, sysdate, :UpdateUserID )"; Paras = new OracleParameter[] { new OracleParameter(":OrderID",OracleDbType.Int32,newOrderID,ParameterDirection.Input), new OracleParameter(":OrderNo",OracleDbType.Varchar2,order.OrderNo,ParameterDirection.Input), new OracleParameter(":OrderDate",OracleDbType.Date,order.OrderDate,ParameterDirection.Input), new OracleParameter(":Remarks",OracleDbType.Varchar2,order.Remarks,ParameterDirection.Input), new OracleParameter(":ValueFlag",OracleDbType.Int32,order.ValueFlag,ParameterDirection.Input), new OracleParameter(":CreateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input), }; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); } else { sql = @"Update TP_PM_Order set OrderNo=:OrderNo, OrderDate=:OrderDate, Remarks=:Remarks, ValueFlag=:ValueFlag, UpdateUserID=:UpdateUserID where OrderID=:OrderID "; Paras = new OracleParameter[] { new OracleParameter(":OrderID",OracleDbType.Int32,order.OrderID,ParameterDirection.Input), new OracleParameter(":OrderNo",OracleDbType.Varchar2,order.OrderNo,ParameterDirection.Input), new OracleParameter(":OrderDate",OracleDbType.Date,order.OrderDate,ParameterDirection.Input), new OracleParameter(":Remarks",OracleDbType.Varchar2,order.Remarks,ParameterDirection.Input), new OracleParameter(":ValueFlag",OracleDbType.Int32,order.ValueFlag,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), }; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); } #endregion if (returnRows <= 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } entity.Result = returnRows; return entity; } /// /// 启用、停用订单标识 /// /// /// /// public static ServiceResultEntity ChangeOrderFlag(OrderEntity order, SUserInfo sUserInfo) { ServiceResultEntity entity = new ServiceResultEntity(); int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { string sql = string.Empty; OracleParameter[] Paras = null; #region 添加、编辑生产订单 sql = @"Update TP_PM_Order set ValueFlag=:ValueFlag, UpdateUserID=:UpdateUserID where OrderID=:OrderID "; Paras = new OracleParameter[] { new OracleParameter(":ValueFlag",OracleDbType.Int32,order.ValueFlag,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":OrderID",OracleDbType.Int32,order.OrderID,ParameterDirection.Input), }; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); #endregion if (returnRows <= 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } entity.Result = returnRows; return entity; } #endregion #region 保存交接 /// /// 保存交接校验 /// /// /// /// /// public static ServiceResultEntity SaveFinishedHandover(int orderid, DataTable dtData, SUserInfo sUserInfo) { ServiceResultEntity entity = new ServiceResultEntity(); IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { string sql = string.Empty; OracleParameter[] Paras = null; DataSet ds = null; bool isError = false; oracleTrConn.Connect(); // 包装装板,产成品交接不限制 //string GoodsModel = string.Empty; //int? logoID = null; //string logoName = string.Empty; //int PlateLimitNum = 0; //string _isEnable_S_PM_011 = "0"; //// 2.产成品交接是否限制同型号 //string _isEnable_S_PM_012 = "0"; //// 3.产成品交接是否限制每板装板数量(必须先启用限制同型号); //string _isEnable_S_PM_013 = "0"; //// 读取系统设置 //sql = "select settingcode,settingvalue from tp_mst_systemsetting where settingcode in ('S_PM_011','S_PM_012','S_PM_013') and accountid=" + sUserInfo.AccountID; //ds = oracleTrConn.GetSqlResultToDs(sql); //foreach (DataRow dr in ds.Tables[0].Rows) //{ // if (dr["settingcode"] == "S_PM_011") // _isEnable_S_PM_011 = dr["settingcode"].ToString(); // else if (dr["settingcode"] == "S_PM_012") // _isEnable_S_PM_012 = dr["settingcode"].ToString(); // else if (dr["settingcode"] == "S_PM_013") // _isEnable_S_PM_013 = dr["settingcode"].ToString(); //} // 本批交接的批次号 string fhBatchNo = System.Guid.NewGuid().ToString(); for (int i = 0; i < dtData.Rows.Count; i++) { #region 产品是否在产成表中 sql = "select FHUserCode,GoodsCode,GoodsID from TP_PM_FinishedProduct where Barcode=:Barcode"; Paras = new OracleParameter[]{ new OracleParameter(":Barcode",OracleDbType.Varchar2, dtData.Rows[i]["barcode"].ToString(),ParameterDirection.Input), }; ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds != null && ds.Tables[0].Rows.Count > 0) { #region 是否交接过 string fhUserCode = ds.Tables[0].Rows[0]["FHUserCode"].ToString(); if (!string.IsNullOrEmpty(fhUserCode)) { entity.Result = -2; //已交接,不能再次进行交接 entity.Message = "此产品【" + dtData.Rows[i]["barcode"].ToString() + "】已交接,不能再次进行交接"; isError = true; break; } #endregion } else { #region 不是产成品 entity.Result = -1; //不是产成品 entity.Message = "此产品【" + dtData.Rows[i]["barcode"].ToString() + "】不是产成品"; isError = true; break; #endregion } #endregion /* 包装装板,产成品交接不限制 if (i == 0) { #region 记录产品型号,最大限制数量,商标 GoodsModel = dtData.Rows[i]["GoodsModel"].ToString(); logoID = Convert.ToInt32(dtData.Rows[i]["logoID"]); logoName = dtData.Rows[i]["logoName"].ToString(); sql = "select PlateLimitNum from TP_MST_Goods where GoodsID=:GoodsID"; Paras = new OracleParameter[]{ new OracleParameter(":GoodsID",OracleDbType.Int32, ds.Tables[0].Rows[0]["GoodsID"],ParameterDirection.Input), }; ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds != null && ds.Tables[0].Rows.Count > 0) { if (_isEnable_S_PM_013 == "1" && _isEnable_S_PM_012 == "1") { PlateLimitNum = Convert.ToInt32(ds.Tables[0].Rows[0]["PlateLimitNum"]); } } #endregion } else { #region 启用限制同商标 if (_isEnable_S_PM_011 == "1") { if (Convert.ToInt32(dtData.Rows[0]["logoid"]) != logoID) { entity.Result = -3; entity.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】的商标【" + dtData.Rows[0]["logoname"] + "】与此批次商标【" + logoName + "】不同,不能进行该操作。 "; isError = true; break; } } #endregion #region 启用限制同型号 if (_isEnable_S_PM_012 == "1") { if (dtData.Rows[0]["GoodsModel"].ToString() != GoodsModel) { entity.Result = -4; entity.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】的型号【" + dtData.Rows[0]["GoodsModel"] + "】与此批次型号【" + GoodsModel + "】不同,不能进行该操作。 "; isError = true; break; } } #endregion #region 产品列表是否大于限制条数 if (PlateLimitNum > 0) { if (dtData.Rows.Count > PlateLimitNum) { entity.Result = -5; entity.Message = "产品列表数量大于每板装板数量【" + PlateLimitNum + "】"; isError = true; break; } } #endregion } */ #region 更新产成品相关信息 sql = @"update TP_PM_FinishedProduct set FHUserID=:FHUserID, FHUserCode=:FHUserCode, FHBatchNo=:FHBatchNo, FHTime=sysdate, FHOrderID=:FHOrderID, UpdateUserID=:UpdateUserID where Barcode=:Barcode"; Paras = new OracleParameter[]{ new OracleParameter(":Barcode",OracleDbType.Varchar2, dtData.Rows[i]["barcode"].ToString(),ParameterDirection.Input), new OracleParameter(":FHUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":FHUserCode",OracleDbType.Varchar2, sUserInfo.UserCode,ParameterDirection.Input), new OracleParameter(":FHBatchNo",OracleDbType.Varchar2, fhBatchNo,ParameterDirection.Input), new OracleParameter(":FHOrderID",OracleDbType.Int32, orderid,ParameterDirection.Input), }; oracleTrConn.ExecuteNonQuery(sql, Paras); #endregion } if (isError) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { entity.Result = 1; oracleTrConn.Commit(); oracleTrConn.Disconnect(); } } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } return entity; } #endregion /// /// 撤销产成品交接 /// /// /// /// public static ServiceResultEntity SaveCancelFinishedHandoverByBarcode(string barcode, SUserInfo sUserInfo) { IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { ServiceResultEntity resultEntity = new ServiceResultEntity(); // 1.判断产品是否在产成品表中 string sql = @"select FHUserID, FHUserCode, GoodsID, GoodsCode, GoodsName from TP_PM_FinishedProduct where BarCode=:BarCode"; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input), }; DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras); if (dsResult != null && dsResult.Tables[0].Rows.Count > 0) { // 在产成品表中 #region 是否交接过 string fhUserCode = dsResult.Tables[0].Rows[0]["FHUserCode"].ToString(); if (string.IsNullOrEmpty(fhUserCode)) { resultEntity.Result = -1; //未交接,不能撤销 resultEntity.Message = "此产品【" + barcode + "】未交接,不能进行该操作"; return resultEntity; } #endregion } else { resultEntity.Result = -2; //不能产成品,不能撤销 sql = "select GoodsCode from TP_PM_GroutingDailyDetail where BarCode=:BarCode"; dsResult = oracleTrConn.GetSqlResultToDs(sql, paras); if (dsResult != null && dsResult.Tables[0].Rows.Count > 0) { resultEntity.Message = "此产品【" + barcode + "】不是产成品,不能进行该操作"; } else { resultEntity.Message = "此条码【" + barcode + "】无效,不能进行该操作"; } return resultEntity; } #region 查询产品相关信息 // 撤销记录 string sqlString = "INSERT INTO TP_PM_FHUndo\n" + " (GroutingDailyDetailID\n" + " ,GoodsLevelTypeID\n" + " ,FHUserID\n" + " ,FHUserCode\n" + " ,FHBatchNo\n" + " ,FHTime\n" + " ,FHOrderID\n" + " ,OnlyCode\n" + " ,FINISHEDLOADBATCHNO\n" + " ,AccountID\n" + " ,CreateUserID)\n" + " SELECT t.groutingdailydetailid\n" + " ,t.GoodsLevelTypeID\n" + " ,t.fhuserid\n" + " ,t.fhusercode\n" + " ,t.fhbatchno\n" + " ,t.fhtime\n" + " ,t.FHOrderID\n" + " ,t.onlycode\n" + " ,t.FINISHEDLOADBATCHNO\n" + " ,t.AccountID\n" + " ,:UpdateUserID\n" + " FROM TP_PM_FinishedProduct t\n" + " WHERE t.barcode = :BarCode"; paras = new OracleParameter[]{ new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), }; int resultRow = oracleTrConn.ExecuteNonQuery(sqlString, paras); // SAP同步后再成品交接撤销的,记录撤销标识 string sapsql = "select count(*) from tsap_hegii_FinishedProduct t where t.barcode = :BarCode and rownum=1"; OracleParameter[] sapparas = new OracleParameter[]{ new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input), }; int sapcount = Convert.ToInt32( oracleTrConn.GetSqlResultToObj(sapsql, sapparas)); if (sapcount > 0) { sapsql = "update tp_pm_groutingdailydetail set SAPFHUndoFlag = '1' where barcode=:BarCode"; oracleTrConn.ExecuteNonQuery(sapsql, sapparas); } sql = @"Update TP_PM_FinishedProduct set FHUserID=null, FHUserCode=null, FHBatchNo=null, FHTime=null, FHOrderID=null,FINISHEDLOADBATCHNO=null, UpdateUserID=:UpdateUserID where BarCode=:BarCode"; resultRow = oracleTrConn.ExecuteNonQuery(sql, paras); if (resultRow == 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { resultEntity.Result = 1; oracleTrConn.Commit(); oracleTrConn.Disconnect(); } #endregion return resultEntity; } catch (Exception ex) { throw ex; } } /// /// 更改产成品交接订单号 /// /// /// /// /// public static ServiceResultEntity SaveChangeFinishedHandoverByBarcode(string barcode, int orderid, SUserInfo sUserInfo) { IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { ServiceResultEntity resultEntity = new ServiceResultEntity(); // 1.判断产品是否在产成品表中 string sql = @"select FHUserID, FHUserCode, GoodsID, GoodsCode, GoodsName from TP_PM_FinishedProduct where BarCode=:BarCode"; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input), }; DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras); if (dsResult != null && dsResult.Tables[0].Rows.Count > 0) { // 在产成品表中 #region 是否交接过 string fhUserCode = dsResult.Tables[0].Rows[0]["FHUserCode"].ToString(); if (string.IsNullOrEmpty(fhUserCode)) { resultEntity.Result = -1; //未交接,不能撤销 resultEntity.Message = "此产品【" + barcode + "】未交接,不能进行该操作"; return resultEntity; } #endregion } else { resultEntity.Result = -2; //不能产成品,不能撤销 sql = "select GoodsCode from TP_PM_GroutingDailyDetail where BarCode=:BarCode"; dsResult = oracleTrConn.GetSqlResultToDs(sql, paras); if (dsResult != null && dsResult.Tables[0].Rows.Count > 0) { resultEntity.Message = "此产品【" + barcode + "】不是产成品,不能进行该操作"; } else { resultEntity.Message = "此条码【" + barcode + "】无效,不能进行该操作"; } return resultEntity; } #region 查询产品相关信息 sql = @"Update TP_PM_FinishedProduct set FHOrderID=:FHOrderID, UpdateUserID=:UpdateUserID where BarCode=:BarCode"; paras = new OracleParameter[]{ new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":FHOrderID",OracleDbType.Int32,orderid,ParameterDirection.Input), }; int resultRow = oracleTrConn.ExecuteNonQuery(sql, paras); if (resultRow == 0) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } else { resultEntity.Result = 1; oracleTrConn.Commit(); oracleTrConn.Disconnect(); } #endregion return resultEntity; } catch (Exception ex) { throw ex; } } /// /// 回收标准计件 /// /// 数据连接对象 /// 工序对象 /// 条码信息 /// 用户基本信息 /// 返回的产品ID /// 返回的产品Code /// 返回的产品名称 /// 返回的注浆者ID /// string /// /// 王鑫 2017.7.20 新建 /// private static string AddRecydingFlagWorkPiece(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo, out int goodsID, out string goodsCode, out string goodsName, out string groutingUserCode, out string logoCode, out string logoName, out string groutingdate) { try { int deleteRow = 0; goodsID = Constant.INT_IS_ZERO; goodsCode = null; goodsName = null; groutingUserCode = string.Empty; //Constant.INT_IS_ZERO; // 获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); string errMsg = string.Empty; // 本批采集的批次号 string centralizedBatchNo = System.Guid.NewGuid().ToString(); // 条码信息 string logoName_Temp = ""; string logoCode_Temp = ""; string groutingdate_Temp = ""; foreach (DataRow barcodeRow in barcodeTable.Rows) { // 条码 string barcode = barcodeRow["Barcode"].ToString(); if (string.IsNullOrEmpty(barcode)) { throw new Exception("传入的条码号为空"); } // 生产工号 int workUserID = Convert.ToInt32(barcodeRow["UserID"]); // 生产工号 string workUserCode = barcodeRow["UserCode"].ToString(); //#region 校验条码有效性 //errMsg = CheckDryRepairBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} //#endregion if (procedure.CollectType == 1) { #region 校验条码有效性 errMsg = CheckRecyclingFlagBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { logoName = ""; logoCode = ""; groutingdate = ""; return errMsg; } #endregion } else { string sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid, tp_pm_groutingdailydetail.goodscode, tp_pm_groutingdailydetail.goodsname, tp_pm_groutingdailydetail.usercode as groutingUserCode, tp_pm_groutingdailydetail.groutingdate, tp_mst_logo.logoid, tp_mst_logo.logocode, tp_mst_logo.logoname from tp_pm_groutingdailydetail left join tp_mst_logo on tp_pm_groutingdailydetail.logoid=tp_mst_logo.logoid where tp_pm_groutingdailydetail.barcode=:barcode "; OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":barcode",barcode), }; DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, paras); if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0) { goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]); goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString(); goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString(); groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString(); logoName = dsGrouting.Tables[0].Rows[0]["logoName"].ToString(); logoCode = dsGrouting.Tables[0].Rows[0]["logoCode"].ToString(); groutingdate = dsGrouting.Tables[0].Rows[0]["groutingdate"].ToString(); logoName_Temp = logoName; logoCode_Temp = logoCode; groutingdate_Temp = groutingdate; } } #region 数据处理 #region 处理废弃数据并转回收数据为在产数据 //////string querysql = @"select GOODSLEVELID from TP_MST_GOODSLEVEL where GOODSLEVELTYPEID=9 and ACCOUNTID=:accountid and VALUEFLAG=1"; //////OracleParameter[] queryparas = new OracleParameter[]{ ////// new OracleParameter(":accountid",OracleDbType.Varchar2, sUserInfo.AccountID,ParameterDirection.Input) //////}; //////DataSet returnDs = oracleTrConn.GetSqlResultToDs(querysql, queryparas); //////if (returnDs == null || returnDs.Tables[0].Rows.Count == 0) //////{ ////// errMsg = "未设定干补等级"; ////// logoName = ""; ////// logoCode = ""; ////// groutingdate = ""; ////// return errMsg; //////} //////string goodsLevelID = returnDs.Tables[0].Rows[0][0].ToString(); //第一步,废弃数据的产品分级类别由 8损坯13不合格14不合格(返) 改为 9干补,产品分级=此账套相应的设置 /*string sqlUpdateLevelTypeString = @"update TP_PM_ScrapProduct set GOODSLEVELID=:GOODSLEVELID, GoodsLevelTypeID=9,SpecialRepairFlag=1, SpecialRepairUserID=:SpecialRepairUserID,SpecialRepairUserCode=:SpecialRepairUserCode,SpecialRepairTime=sysdate, UpdateUserID=:UpdateUserID where BarCode=:barcode and CreateTime=(select max(CreateTime) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1) and ValueFlag=1 and GoodsLevelTypeID=(select max(GoodsLevelTypeID) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1) "; */ // and ValueFlag=1 and GoodsLevelTypeID=8 "; ////// string sqlUpdateLevelTypeString = @"update TP_PM_ScrapProduct set GOODSLEVELID=:GOODSLEVELID, GoodsLevelTypeID=9, ////// SpecialRepairUserID=:SpecialRepairUserID,SpecialRepairUserCode=:SpecialRepairUserCode,SpecialRepairTime=sysdate, ////// UpdateUserID=:UpdateUserID ////// where BarCode=:barcode ////// and CreateTime=(select max(CreateTime) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1) ////// and ValueFlag=1 and GoodsLevelTypeID in (8, 13, 14) "; string sqlUpdateLevelTypeString = @"update TP_PM_ScrapProduct set RecyclingFlag=1, UpdateUserID=:UpdateUserID,RecyclingUserID=:RecyclingUserID,RecyclingUserCode=:RecyclingUserCode, RecyclingTime=sysdate where BarCode=:barcode and CreateTime=(select max(CreateTime) from TP_PM_ScrapProduct where BarCode=:barcode and ValueFlag=1) and ValueFlag=1 "; OracleParameter[] ScrapProductparas = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":RecyclingUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":RecyclingUserCode",OracleDbType.Varchar2, sUserInfo.UserCode,ParameterDirection.Input), }; oracleTrConn.ExecuteNonQuery(sqlUpdateLevelTypeString, ScrapProductparas); string sqlUpdateGROUTString = @"update TP_PM_GROUTINGDAILYDETAIL set RecyclingFlag=1, UpdateUserID=:UpdateUserID where BarCode=:barcode "; OracleParameter[] GROUTparas = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), }; oracleTrConn.ExecuteNonQuery(sqlUpdateGROUTString, GROUTparas); //modify wangx 20150623 //////OracleParameter[] sqlUpdateparas = new OracleParameter[]{ ////// new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), //////}; //string sqlUpdate = "update TP_PM_InCheckedDetail set SpecialRepairFlag=1 where barcode=:barcode"; //oracleTrConn.ExecuteNonQuery(sqlUpdate, sqlUpdateparas); //////string sqlUpdate = "update TP_PM_ProductionDataIn set SpecialRepairFlag=1 where barcode=:barcode"; //////oracleTrConn.ExecuteNonQuery(sqlUpdate, sqlUpdateparas); //modify wangx 20150623 end #region //第五步,插入回收工序的生产数据(同其他计件工序),设置干补标识,产品分级类别=9干补,产品分级=此账套相应的设置 // 查询新插入的生产数据ID string sql = "select SEQ_PM_ProductionData_ID.nextval from dual"; string idStr = oracleTrConn.GetSqlResultToStr(sql); int productionDataID = 0; if (!string.IsNullOrEmpty(idStr)) { productionDataID = int.Parse(idStr); } else { logoName = ""; logoCode = ""; groutingdate = ""; return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } int? ClassesSettingID = null;//班次配置ID #region 第五步 添加生产者数据 errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID); if (!string.IsNullOrEmpty(errMsg)) { logoName = ""; logoCode = ""; groutingdate = ""; return errMsg; } #endregion ProductionDataEntity productionData = new ProductionDataEntity(); #region 属性赋值 productionData.ClassesSettingID = ClassesSettingID; productionData.ProductionDataID = Convert.ToInt32(idStr); productionData.Barcode = barcode; productionData.CentralizedBatchNo = centralizedBatchNo; productionData.ProductionLineID = procedure.ProductionLineID; productionData.ProductionLineCode = procedure.ProductionlineCode; productionData.ProductionLineName = procedure.ProductionlineName; productionData.CompleteProcedureID = procedure.ProcedureID; productionData.ProcedureCode = procedure.ProcedureCode; productionData.ProcedureName = procedure.ProcedureName; productionData.ProcedureModel = procedure.ProcedureModel; productionData.ModelType = procedure.ModelType; productionData.NodeType = procedure.NodeType; productionData.DefectFlag = (int)Constant.DefectFlag.No; productionData.ReworkProcedureID = null; productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode); productionData.IsReFire = (int)Constant.ReFireFlag.No; //设置干补标识,产品分级类别=9干补 ////productionData.GoodsLevelTypeID = 9; //productionData.GoodsLevelID = int.Parse(goodsLevelID); //productionData.GoodsGrade = (int)Constant.GoodsGrade.Good; productionData.OrganizationID = procedure.OrganizationID; productionData.GoodsID = goodsID; productionData.GoodsCode = goodsCode; productionData.GoodsName = goodsName; productionData.UserID = workUserID; productionData.UserCode = barcodeRow["UserCode"].ToString(); productionData.UserName = barcodeRow["UserName"].ToString(); productionData.PieceType = procedure.PieceType; if (barcodeRow["LogoID"].ToString() != "") { productionData.LogoID = Convert.ToInt32(barcodeRow["LogoID"]); } string sqlReFire = @"select isrefire, logoid,GoodsLevelID,GoodsLevelTypeID from tp_pm_inproduction where barcode=:barcode union select isrefire, logoid,GoodsLevelID,GoodsLevelTypeID from TP_PM_InProductionTrash where barcode=:barcode union select isrefire, logoid,GoodsLevelID,GoodsLevelTypeID from TP_PM_FinishedProduct where barcode=:barcode "; OracleParameter[] ReFireparas = new OracleParameter[] { new OracleParameter(":barcode",barcode), }; DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas); if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0) { productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]); } if (dsReFire.Tables[0].Rows[0]["logoid"].ToString() != "") { productionData.LogoID = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["LogoID"]); } if (dsReFire.Tables[0].Rows[0]["GoodsLevelTypeID"].ToString() != string.Empty) { productionData.GoodsLevelTypeID = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["GoodsLevelTypeID"]); productionData.GoodsLevelID = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["GoodsLevelID"]); } } #endregion 属性赋值 productionData.SpecialRepairflag = 0; string OutSpecialRepairflag = "0";// 没有什么特殊的,同干补保存生产数据共用同一个方法 errMsg = AddDryRepairProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); if (!string.IsNullOrEmpty(errMsg)) { logoName = ""; logoCode = ""; groutingdate = ""; return errMsg; } #endregion //第二步,回收站中数据回到在产中,设置干补标识。 string sqlInsInProdString = @"insert into TP_PM_InProduction(BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid, ISREWORKFLAG, SEMICHECKID) select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME, :PROCEDUREMODEL, :MODELTYPE, null, ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME, USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE, GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID, CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE, REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME, CREATEUSERID, UPDATETIME, :UpdateUserID, ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, 1, GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM, KILNID, KILNCODE, KILNNAME, KILNCARID, KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,:ProcedureID ,--FlowProcedureID FlowProcedureTime,:ProcedureID,sysdate,:ProductionDataID,logoid, ISREWORKFLAG, SEMICHECKID from TP_PM_InProductionTrash where barcode=:barcode "; OracleParameter[] InProductparas = new OracleParameter[]{ new OracleParameter(":UpdateUserID",OracleDbType.Int32, workUserID,ParameterDirection.Input), ////new OracleParameter(":GOODSLEVELID",OracleDbType.Int32,int.Parse(goodsLevelID),ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), new OracleParameter(":ProcedureID",OracleDbType.Int32,procedure.ProcedureID,ParameterDirection.Input), new OracleParameter(":PROCEDUREMODEL",OracleDbType.Varchar2,procedure.ProcedureModel,ParameterDirection.Input), new OracleParameter(":MODELTYPE",OracleDbType.Int32,procedure.ModelType,ParameterDirection.Input), new OracleParameter(":ProductionDataID",OracleDbType.Int32,productionDataID,ParameterDirection.Input) }; //第三步,删除回收站中的条码 string sqlDelInProductTrashString = "delete from TP_PM_InProductionTrash where barcode=:barcode "; OracleParameter[] TrashProductparas = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; //第四步,更新注浆表干补标识 // string sqlUpGroutingDeilString = @"update TP_PM_GroutingDailyDetail set SpecialRepairFlag=1 // where GroutingDailyDetailID=(select GroutingDailyDetailID from TP_PM_GROUTINGPRODUCT // where barcode=:barcode)"; ////// string sqlUpGroutingDeilString = @"update TP_PM_GroutingDailyDetail set SpecialRepairFlag=1 ////// where barcode=:barcode"; ////// OracleParameter[] GroutingProductparas = new OracleParameter[]{ ////// new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) ////// }; // string sqlUpCompleteString = @"update TP_PM_FINISHEDPRODUCT set SpecialRepairFlag=1 // where barcode=:barcode "; // OracleParameter[] CompleteProductparas = new OracleParameter[]{ // new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) // }; deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpdateLevelTypeString, ScrapProductparas); deleteRow += oracleTrConn.ExecuteNonQuery(sqlInsInProdString, InProductparas); deleteRow += oracleTrConn.ExecuteNonQuery(sqlDelInProductTrashString, TrashProductparas); //deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpGroutingDeilString, GroutingProductparas); //deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpCompleteString, CompleteProductparas); //由于成品后,不能报损,所以这个执行去掉 // 失败 if (deleteRow == Constant.INT_IS_ZERO) { logoName = ""; logoCode = ""; groutingdate = ""; return string.Format(Messages.MSG_CMN_W001, "条码", "保存"); } #endregion //#region 第五步 添加生产者数据 //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo); //if (!string.IsNullOrEmpty(errMsg)) //{ // return errMsg; //} //#endregion //第五步,回添加生产数据 modify wangx 2015/07/20 新添加的代码 sql = "select 1 from tp_pm_productiondatain where barcode=:barcode and valueflag=1"; OracleParameter[] Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras); if (ds.Tables[0].Rows.Count == 0) { // 2 生产数据恢复到在产生产数据 sql = @"insert into tp_pm_productiondatain ( ProductionDataID, BarCode, CentralizedBatchNo, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureID, ProcedureCode, ProcedureName, ProcedureModel, ModelType, PieceType, IsReworked, NodeType, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, SpecialRepairFlag, OrganizationID, GoodsID, GoodsCode, GoodsName, UserID, UserCode, UserName, ClassesSettingID, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, ReworkProcedureID, ReworkProcedureCode, ReworkProcedureName, GroutingDailyID, GroutingDailyDetailID, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingDate, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, AccountDate, SettlementFlag, AccountID, ValueFlag, CreateTime, CreateUserID, UpdateTime, UpdateUserID, OPTimeStamp, TriggerFlag, logoid, BackOutTime,BackOutUserID,BackOutUserCode ) select ProductionDataID, BarCode, CentralizedBatchNo, ProductionLineID, ProductionLineCode, ProductionLineName, ProcedureID, ProcedureCode, ProcedureName, ProcedureModel, ModelType, PieceType, IsReworked, NodeType, IsPublicBody, IsReFire, GoodsLevelID, GoodsLevelTypeID, SpecialRepairFlag, OrganizationID, GoodsID, GoodsCode, GoodsName, UserID, UserCode, UserName, ClassesSettingID, KilnID, KilnCode, KilnName, KilnCarID, KilnCarCode, KilnCarName, KilnCarBatchNo, KilnCarPosition, ReworkProcedureID, ReworkProcedureCode, ReworkProcedureName, GroutingDailyID, GroutingDailyDetailID, GroutingLineID, GroutingLineCode, GroutingLineName, GMouldTypeID, CanManyTimes, GroutingLineDetailID, GroutingDate, GroutingMouldCode, MouldCode, GroutingUserID, GroutingUserCode, GroutingNum, Remarks, AccountDate, SettlementFlag, AccountID, ValueFlag, CreateTime, CreateUserID, UpdateTime, UpdateUserID, OPTimeStamp, 1, logoid, BackOutTime,BackOutUserID,BackOutUserCode from TP_PM_ProductionData where valueflag=1 and barcode=:barcode "; oracleTrConn.ExecuteNonQuery(sql, Paras); } //第五步,回添加生产数据 modify wangx 2015/07/20 新添加的代码 end #endregion 数据处理 } logoName = logoName_Temp; logoCode = logoCode_Temp; groutingdate = groutingdate_Temp; return errMsg; } catch (Exception ex) { throw ex; } } /// /// 校验回收条码有效 /// /// 连接对象 /// 工序ID /// 条码 /// 返回的产品ID /// 返回的产品Code /// 返回的产品名称 /// 返回的注浆者ID /// string /// /// 王鑫 2017.7.20 新建 /// private static string CheckRecyclingFlagBarcode(IDBTransaction oracleTrConn, int procedureID, string barcode, out int goodsID, out string goodsCode, out string goodsName, out string groutingUserCode, SUserInfo sUserInfo ) { try { //OracleParameter[] paras = new OracleParameter[]{ // new OracleParameter("in_procedureid",OracleDbType.Int32,procedureID,ParameterDirection.Input), // new OracleParameter("in_barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input), // new OracleParameter("out_errMsg",OracleDbType.Varchar2,2000,"",ParameterDirection.Output), // new OracleParameter("out_goodsID",OracleDbType.Int32,ParameterDirection.Output), // new OracleParameter("out_goodsCode",OracleDbType.Varchar2,50,"",ParameterDirection.Output), // new OracleParameter("out_goodsName",OracleDbType.Varchar2,50,"",ParameterDirection.Output), // new OracleParameter("out_groutingUserCode",OracleDbType.NVarchar2,50,null,ParameterDirection.Output), //}; //oracleTrConn.ExecStoredProcedure("pro_pm_checkdryrepairbarcode", paras); //if (!"null".Equals(paras[3].Value + "")) //{ // goodsID = Convert.ToInt32(paras[3].Value + ""); //} //else //{ // goodsID = 0; //} //goodsCode = paras[4].Value + ""; //goodsName = paras[5].Value + ""; //if (!"null".Equals(paras[6].Value + "")) //{ // groutingUserCode = paras[6].Value + ""; //} //else //{ // groutingUserCode = null; //} //if ("null".Equals(paras[2].Value + "")) //{ // return null; //} //return paras[2].Value.ToString().Replace("\\n\\r", "\n\r"); string errorMessage = string.Empty; goodsID = 0; goodsCode = string.Empty; goodsName = string.Empty; groutingUserCode = string.Empty; string sqlString = @"select settingcode,settingvalue,settingdefaultvalues from tp_mst_systemsetting where Accountid=:Accountid and settingcode in ('S_PM_017','S_PM_018','S_PM_019','S_PM_020')"; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter("Accountid",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input), }; DataSet ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); #region 读出系统配置 17(损坯可否回收) 18(半检不合格可否回收) 19(复检不合格可否回收) 20(次品可否回收) int S_PM_017_Value = 0, S_PM_018_Value = 0, S_PM_019_Value = 0, S_PM_020_Value = 0; if (ds != null && ds.Tables[0].Rows.Count > 0) { foreach (DataRow r in ds.Tables[0].Rows) { if (r["settingcode"].ToString() == "S_PM_017") { S_PM_017_Value = Convert.ToInt32(r["settingvalue"]); } else if (r["settingcode"].ToString() == "S_PM_018") { S_PM_018_Value = Convert.ToInt32(r["settingvalue"]); } else if (r["settingcode"].ToString() == "S_PM_019") { S_PM_019_Value = Convert.ToInt32(r["settingvalue"]); } else if (r["settingcode"].ToString() == "S_PM_020") { S_PM_020_Value = Convert.ToInt32(r["settingvalue"]); } } } #endregion #region 第1步 查当前工序在系统是否存在 sqlString = @"select NodeType,ModelType from tp_pc_procedure where procedureid=:procedureid and ValueFlag=1"; paras = new OracleParameter[]{ new OracleParameter(":procedureid",procedureID), }; ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); if (ds == null || ds.Tables[0].Rows.Count == 0) { errorMessage = "当前工序在系统中不存在"; return errorMessage; } #endregion #region 第2步 查产品是否有效 sqlString = @"select distinct GoodsID, GoodsCode,GoodsName,UserCode,DeliverFlag from TP_PM_GroutingDailyDetail where BarCode=:barCode and ValueFlag=1 "; paras = new OracleParameter[]{ new OracleParameter(":barCode",barcode), }; ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); if (ds == null || ds.Tables[0].Rows.Count == 0) { // 是否被替换 string sql = @"select count(barcode),max(newbarcode) from TP_PM_BarCodeRecord where BarCode=:barcode"; OracleParameter[] paras2 = new OracleParameter[]{ new OracleParameter(":barCode",barcode) }; DataSet ds2 = oracleTrConn.GetSqlResultToDs(sql, paras2); if (ds2 != null && Convert.ToInt32(ds2.Tables[0].Rows[0][0]) == 0) { // 无效条件 errorMessage = "无效条码[" + barcode + "]"; } else { errorMessage = "条码[" + barcode + "]已经被[" + ds2.Tables[0].Rows[0][1] + "]替换"; } } else { if (Convert.ToInt32(ds.Tables[0].Rows[0]["DeliverFlag"]) != 1) { errorMessage = "条码[" + barcode + "]未交坯,不能回收"; } else { goodsID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsID"]); goodsName = ds.Tables[0].Rows[0]["goodsName"].ToString(); goodsCode = ds.Tables[0].Rows[0]["GoodsCode"].ToString(); groutingUserCode = ds.Tables[0].Rows[0]["UserCode"].ToString(); } } if (!string.IsNullOrEmpty(errorMessage)) { return errorMessage; } #endregion #region 第3步 查产品是否在当前工序配置 sqlString = @"select count(GoodsID) from TP_PC_ProcedureGoods where GoodsID=:GoodsID and ProcedureID=:ProcedureID"; paras = new OracleParameter[]{ new OracleParameter(":GoodsID",goodsID), new OracleParameter(":ProcedureID",procedureID), }; ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); if (Convert.ToInt32(ds.Tables[0].Rows[0][0]) != 1) { errorMessage = @"条码[" + barcode + "]不可以经过该工序\n\r原因:条码对应的产品编码[" + goodsCode + "]没有在该工序中配置"; } if (!string.IsNullOrEmpty(errorMessage)) { return errorMessage; } #endregion #region 第4步,校验在产产品不能回收 string sqlString2 = "select InScrapFlag,ISREWORKFLAG from tp_pm_inproduction where barcode=:barcode"; OracleParameter[] parasNew = new OracleParameter[]{ new OracleParameter(":barcode",barcode) }; DataSet dsNew = oracleTrConn.GetSqlResultToDs(sqlString2, parasNew); if (dsNew != null && dsNew.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(dsNew.Tables[0].Rows[0]["InScrapFlag"]) == 1) { errorMessage = "报损待审产品不能回收"; } else if (Convert.ToInt32(dsNew.Tables[0].Rows[0]["ISREWORKFLAG"]) == 1) { errorMessage = "半检返工中不能回收"; } else { errorMessage = "在产产品不能回收"; } } if (!string.IsNullOrEmpty(errorMessage)) { return errorMessage; } #endregion #region 第4步,校验报损表数据是否可以回收 sqlString = @"select GoodsLevelID,GoodsLevelTypeID,ScrapType,SpecialRepairFlag,RecyclingFlag,AuditStatus,SpecialRepairUserID from TP_PM_ScrapProduct where barcode=:barcode and ValueFlag=1 and CreateTime= (select max(CreateTime) from TP_PM_ScrapProduct where barcode=:barcode and ValueFlag=1 )"; paras = new OracleParameter[]{ new OracleParameter(":barcode",barcode), }; ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); if (ds == null || ds.Tables[0].Rows.Count == 0) { errorMessage = "不存在回收数据,不能回收"; } else { if (Convert.ToInt32(ds.Tables[0].Rows[0]["AuditStatus"]) == 1 && Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]) != 9 && Convert.ToInt32(ds.Tables[0].Rows[0]["RecyclingFlag"]) == 0) { // 可回收 string sqlString3 = "select 1 from tp_pm_inproductiontrash where barcode=:barcode"; OracleParameter[] parasNewt = new OracleParameter[]{ new OracleParameter(":barcode",barcode) }; DataSet dsNewt = oracleTrConn.GetSqlResultToDs(sqlString3, parasNewt); if (dsNewt == null || dsNewt.Tables[0].Rows.Count == 0) { errorMessage = "报损数据被清除,不能回收"; } } else { errorMessage = "不存在回收数据,不能回收"; } if (!string.IsNullOrEmpty(errorMessage)) { if (Convert.ToInt32(ds.Tables[0].Rows[0]["ScrapType"]) == 0) { // 损坯 if (S_PM_017_Value == 0) { errorMessage = "系统参数产品回收-报损未启用"; } } else if (Convert.ToInt32(ds.Tables[0].Rows[0]["ScrapType"]) == 1) { // 成检 if (S_PM_020_Value == 0) { errorMessage = "系统参数产品回收-次品未启用"; } } else if (Convert.ToInt32(ds.Tables[0].Rows[0]["ScrapType"]) == 2) { // 半检 if (S_PM_018_Value == 0) { errorMessage = "系统参数产品回收-半检不合格未启用"; } } else if (Convert.ToInt32(ds.Tables[0].Rows[0]["ScrapType"]) == 3) { // 复检 if (S_PM_019_Value == 0) { errorMessage = "系统参数产品回收-复检不合格未启用"; } } } } #endregion return errorMessage; } catch (Exception ex) { throw ex; } } } }