using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.IO; using System.Net; 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.CMNModuleService; using Dongke.IBOSS.PRD.Service.DataModels; using Dongke.IBOSS.PRD.Service.SAPHegiiDataService; using Dongke.IBOSS.PRD.Service.WMSDataService; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.DataModels.PMModule; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Oracle.ManagedDataAccess.Client; using static Dongke.IBOSS.PRD.Service.SAPHegiiDataService.SAPDataLogic; namespace Dongke.IBOSS.PRD.Service.PCModuleService { public static class FinishedCheckLogic { #region 生产管理 #region 计件 /// /// 添加生产计件 /// /// 工序ID /// 条码信息 /// 用户基本信息 /// DataTable null:添加成功 不为空:错误消息 /// /// 陈冰 2014.09.18 新建 /// public static DataTable AddWorkPiece(int procedureID, DataTable barcodeTable, SUserInfo sUserInfo, out ProcedureEntity procedureInfo) { procedureInfo = null; if (barcodeTable == null || barcodeTable.Rows.Count == 0) { return null; } // 实例返回的Talbe DataTable dtBarCode = 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 //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的 //xuwei fix 2019-09-26 按原条理判定首节点得到正确的返回结果 // 2019-1016 if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { int nodeBegin = IsNodeBegin(oracleTrConn, barcodeTable.Rows[0]["Barcode"].ToString()); if (nodeBegin == 1) { procedure.NodeType = (int)Constant.ProcedureNodeType.Begin; } else if (nodeBegin == 0) { procedure.NodeType = (int)Constant.ProcedureNodeType.Middle; } } //if (nodeBegin == -1) errMsg = "条码不正确,请检查!"; #region 标准计件和坯库 if (procedure.ModelType == (int)Constant.ProcedureModelType.Normal || procedure.ModelType == (int)Constant.ProcedureModelType.AdobeStock //xuwei add 2020-06-11 冷补更改窑车批车 || procedure.ModelType == (int)Constant.ProcedureModelType.ColdPatch) { if (procedure.CollectType == 1) { #region 集中采集 errMsg = AddNormalWorkPiece(oracleTrConn, procedure, barcodeTable, sUserInfo, out goodsID, out goodsCode, out goodsName, out groutingUserCode); #endregion } else { #region 单点采集 int? GroutingDailyDetailID = null; if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { dsReturnSinglePoint = CheckBarcodeDeliverMudSinglePoint(procedureID, barcodeTable.Rows[0]["barcode"].ToString(), sUserInfo, ref GroutingDailyDetailID); } else { dsReturnSinglePoint = 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 } } #endregion #region 交坯 else if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud) { if (procedure.CollectType == 1) { #region 集中采集 //xuwei fix begin 2019-09-17 //加入最后一个参数 true,识别为交坏 errMsg = AddNormalWorkPiece(oracleTrConn, procedure, barcodeTable, sUserInfo, out goodsID, out goodsCode, out goodsName, out groutingUserCode, true); //xuwei end #endregion } else { #region 单点采集 int? GroutingDailyDetailID = null; if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { dsReturnSinglePoint = CheckBarcodeDeliverMudSinglePoint(procedureID, barcodeTable.Rows[0]["barcode"].ToString(), sUserInfo, ref GroutingDailyDetailID); } else { dsReturnSinglePoint = CheckBarcodeSinglePoint(procedureID, barcodeTable.Rows[0]["barcode"].ToString(), sUserInfo); } //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(); //xuwei fix begin 2019-09-17 //加入最后一个参数 true,识别为交坏 errMsg = AddNormalWorkPieceSinglePoint(oracleTrConn, procedure, barcodeTable, sUserInfo, goodsID, goodsCode, goodsName, groutingUserCode, GroutingDailyDetailID, true); 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 = 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(); //xuwei fix begin 2019-09-17 //加入最后一个参数 true,识别为交坏 errMsg = AddNormalWorkPieceSinglePoint(oracleTrConn, procedure, barcodeTable, sUserInfo, goodsID, goodsCode, goodsName, groutingUserCode, GroutingDailyDetailID, true); 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 = 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(); //xuwei fix begin 2019-09-17 //加入最后一个参数 true,识别为交坏 errMsg = AddNormalWorkPieceSinglePoint(oracleTrConn, procedure, barcodeTable, sUserInfo, goodsID, goodsCode, goodsName, groutingUserCode, GroutingDailyDetailID, true); 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 = 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 } } #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.ModelType == (int)Constant.ProcedureModelType.ColdPatch) && 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 // 工序保存有错误时,不进行后续PLC操作 add by chenxy 2020-09-18 if (string.IsNullOrEmpty(errMsg)) { errMsg = dtBarCode.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] + ""; } // 工序保存有错误时,不进行后续PLC操作 if (!string.IsNullOrEmpty(errMsg)) { // 如果是3#刮蹬,调用PLC接口 2020-09-07 fubin if (procedure.ProcedureID == 99) { string sql = "select t.flowprocedureid from tp_pm_inproduction t where t.barcode ='" + barcodeTable.Rows[0]["Barcode"] + "'"; object flowprocedureid = oracleTrConn.GetSqlResultToObj(sql); if (flowprocedureid + "" == "99") { Hashtable plcPara = new Hashtable(); plcPara.Add("finishflag", 1); string errMsg1 = PLCModuleLogic.PlcWrite2(3201, plcPara).Message; if (string.IsNullOrEmpty(errMsg1)) { errMsg1 = System.Environment.NewLine + "【PLC】线体可以放行"; } else { errMsg1 = System.Environment.NewLine + "【PLC】" + errMsg1; } dtBarCode.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = errMsg + errMsg1; } } // errMsg 有值,dtBarCode中无值时,要写入dtBarCode中,将错误信息返回给前台 //string mm = dtBarCode.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] + ""; //if (mm != errMsg) { dtBarCode.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = errMsg; } return dtBarCode; } // 如果是3#包装,更新三车间包装标识 if (procedure.ProcedureID == 107) { string sql = string.Empty; int r = 0; foreach (DataRow row in barcodeTable.Rows) { sql = "UPDATE tp_pm_groutingdailydetail gdd\n" + " SET gdd.packingby3 = '1'\n" + " WHERE gdd.barcode = '" + row["Barcode"] + "'"; r += oracleTrConn.ExecuteNonQuery(sql); } } // 如果是3#上水,调用PLC接口 2020-09-03 fubin if (procedure.ProcedureID == 94) { /* 暂时不对接,上水机械臂暂停 2020-10-24 chenxy string sql = "SELECT g.seatcovercode\n" + " FROM tp_pm_groutingdailydetail p\n" + " LEFT JOIN tp_mst_goods g\n" + " ON g.goodsid = p.goodsid\n" + " WHERE p.valueflag = '1'\n" + " AND p.barcode = '" + barcodeTable.Rows[0]["Barcode"] + "'"; object goodsModel = oracleTrConn.GetSqlResultToObj(sql); Hashtable plcPara = new Hashtable(); if (goodsModel.ToInt32() != 0) { plcPara.Add("goodsmodel", goodsModel); plcPara.Add("finishflag", 1); plcPara.Add("errorflag", 0); } else { plcPara.Add("goodsmodel", 0); plcPara.Add("finishflag", 1); plcPara.Add("errorflag", 1); } errMsg = PLCModuleLogic.PlcWrite2(3320, plcPara, sUserInfo.UserCode).Message; */ } // 如果是3#刮蹬,调用PLC接口 2020-09-07 fubin if (procedure.ProcedureID == 99) { Hashtable plcPara = new Hashtable(); plcPara.Add("finishflag", 1); //xuwei modify 2021-12-24 按打卡工号识别线号 errMsg = PLCModuleLogic.PlcWrite2(3201, plcPara, sUserInfo.UserCode).Message; } // 没有错误 提交事务 if (string.IsNullOrEmpty(errMsg)) { oracleTrConn.Commit(); } else { dtBarCode.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = errMsg; } } 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, bool isSendBody = false ) { 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().ToUpper(); 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) { #region 集中采集 校验条码 // ccc todo //if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的 if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { #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 } #endregion } else { #region 单点采集 获取注浆日报明细 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(); } #endregion } 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 //xuwei fix 2019-09-23 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的 //xuwei fix 2019-09-26 使用通用方法判定 //if (IsNodeBegin(oracleTrConn, barcode) == 1) // procedure.NodeType = (int)Constant.ProcedureNodeType.Begin; #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; //xuwei add 2020-06-11 冷补更新窑车批车号 if (procedure.ProcedureID == 135) productionData.KilnCarBatchNo = centralizedBatchNo; 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 if (procedure.IsSpecialRework == 2) { productionData.IsLengBu = 1; 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) { //添加首节点数据 (在产生产数据) //xuwei fix 2019-09-17 添加最后一个可选参数isSendBody识别交坯 errMsg = AddProductionDataDeliverMud(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, out outDataSet, isSendBody); } else { //添加非首节点数据 //xuwei fix 2019-09-17 添加最后一个可选参数isSendBody识别交坯 errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, isSendBody); } 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; //xuwei add 2020-06-11 冷补更新窑车批车号 if (procedure.ProcedureID == 135) addInProductionEntity.KilnCarBatchNo = centralizedBatchNo; #region 交坯判断 addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯 #endregion // 生产工号 addInProductionEntity.UserID = workUserID; // 执行添加 //xuwei fix 2019-09-17 添加最后一个可选参数isSendBody识别交坯 errMsg = AddInProduction(oracleTrConn, addInProductionEntity, sUserInfo, outDataSet, isSendBody); // 执行失败 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; //xuwei add 2020-06-11 冷补更新窑车批车号 if (procedure.ProcedureID == 135) addInProductionEntity.KilnCarBatchNo = centralizedBatchNo; // 生产工号 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; } // 2是冷补 else if (procedure.IsSpecialRework == 2) { addInProductionEntity.IsLengBu = 1; 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 #region 更新注浆明细上的冷补标识 if (productionData.IsLengBu == 1) { oracleTrConn.ExecuteNonQuery(@" UPDATE tp_pm_groutingdailydetail SET ISLENGBU = '1' WHERE BARCODE = :BARCODE ", new OracleParameter[] { new OracleParameter(":BARCODE", productionData.Barcode) }); } #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().ToUpper(); // 窑车批次号 string kilnCarBatchNo = System.Guid.NewGuid().ToString().ToUpper(); // 窑车状态 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)) { // 自动生成窑车烧成批次号 kilnCarBatchNo = GetFiredKilnCarBatchNo(oracleTrConn, kilnCarID); // 插入窑车状态表 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().ToUpper(); // 窑车批次号 string kilnCarBatchNo = System.Guid.NewGuid().ToString().ToUpper(); // 窑车状态 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().ToUpper(); // 窑车批次号 string kilnCarBatchNo = System.Guid.NewGuid().ToString().ToUpper(); // 窑车状态 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().ToUpper(); string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo; // 窑车批次号 string kilnCarBatchNo = null;//System.Guid.NewGuid().ToString().ToUpper(); // 窑车状态 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().ToUpper(); // 窑车Code string kilnCarCode = barcodeTable.Rows[0]["kilnCarCode"].ToString(); // 窑车批次号 string kilnCarBatchNo = System.Guid.NewGuid().ToString().ToUpper(); // 窑车状态 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().ToUpper(); return GetFiredKilnCarBatchNo(oracleTrConn, kilnCarID); } } /// /// 自动生成窑车烧成批次号 /// /// /// /// public static string GetFiredKilnCarBatchNo(IDBTransaction oracleTrConn, int kilnCarID) { DateTime now = DateTime.Now.Date; string sqlString = "select k.kilnid, k.kilncode, k.fireddate, k.firedbatchno, kc.kilncarcode, k.sk_date, k.sk_batchno\n" + " from TP_MST_Kiln k\n" + " inner join tp_mst_kilncar kc\n" + " on k.kilnid = kc.kilnid\n" + " where kc.kilncarid = :kilncarid\n" + //" and k.fireddate = :fireddate" " for update"; OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":kilncarid",kilnCarID), //new OracleParameter(":fireddate",now), }; DataTable dt = oracleTrConn.GetSqlResultToDt(sqlString, paras); if (dt == null || dt.Rows.Count == 0) { // 窑车、窑炉不存在 return null; } int kilnid = Convert.ToInt32(dt.Rows[0]["kilnid"]); string kilncode = dt.Rows[0]["kilncode"] + ""; string kilncarcode = dt.Rows[0]["kilncarcode"] + ""; int sk_date = Convert.ToInt32(dt.Rows[0]["sk_date"]); int sk_batchno = Convert.ToInt32(dt.Rows[0]["sk_batchno"]); int firedbatchno = 0; if (dt.Rows[0]["fireddate"] == null || dt.Rows[0]["fireddate"] == DBNull.Value) { firedbatchno = -1; } else { DateTime fireddate = Convert.ToDateTime(dt.Rows[0]["fireddate"]); if (now > fireddate) { firedbatchno = -1; } } if (firedbatchno < 0) { // 当日第一车 sqlString = "update TP_MST_Kiln k\n" + " set k.fireddate = :fireddate, k.firedbatchno = 1\n" + " where k.kilnid = :kilnid"; paras = new OracleParameter[] { new OracleParameter(":kilnid",kilnid), new OracleParameter(":fireddate",now), }; oracleTrConn.ExecuteNonQuery(sqlString, paras); return $"{kilncode}${sk_date}${sk_batchno.ToString("000")}${kilncarcode}${now.ToString("yyyyMMdd")}$001"; } firedbatchno = Convert.ToInt32(dt.Rows[0]["firedbatchno"]) + 1; sqlString = "update TP_MST_Kiln k\n" + " set k.firedbatchno = k.firedbatchno + 1\n" + " where k.kilnid = :kilnid"; paras = new OracleParameter[] { new OracleParameter(":kilnid",kilnid), }; oracleTrConn.ExecuteNonQuery(sqlString, paras); return $"{kilncode}${sk_date}${sk_batchno.ToString("000")}${kilncarcode}${now.ToString("yyyyMMdd")}${firedbatchno.ToString("000")}"; } /// /// 插入窑车状态表 /// /// 连接对象 /// 工序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 新建 /// xuwei 2019-09-17 修改 /// private static string AddProductionDataDeliverMud(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag , out DataSet outGroutingProduct, bool isSendBody = false) { #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号 string selectSql = ""; string returnVal = ""; //xuwei fix 2019-09-23 修正非交坯时 productionData.GroutingDailyDetailID 为空无法得到结果 //改用 条码查询 //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), //}; 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.Barcode=:Barcode"; OracleParameter[] selectparas1 = new OracleParameter[] { new OracleParameter(":Barcode",productionData.Barcode), }; //xuwei fix end 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"]); } //xuwei fix begin //2019-09-17 //更新注浆日报(交坯处理) if (isSendBody) { 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); } //更新 注浆日报 在产标识(BEGINNINGFLAG) selectSql = "update TP_PM_GroutingDailyDetail set BEGINNINGFLAG = '1' where Barcode='" + productionData.Barcode + "'"; oracleTrConn.ExecuteNonQuery(selectSql); //xuwei end } 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, bool isSendBody = false) { #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 ip.GroutingDate, ip.GroutingUserID, ip.GroutingUserCode, ip.GroutingNum, ip.GroutingMouldCode, ip.MouldCode, ip.GroutingDailyID, ip.GroutingDailyDetailID, ip.GroutingLineID, ip.GroutingLineCode, ip.GroutingLineName, ip.GMouldTypeID, ip.CanManyTimes, ip.GroutingLineDetailID, ip.SpecialRepairflag, ip.IsReFire, ip.logoid, gdd.ClassesSettingID from tp_pm_inproduction ip inner join TP_PM_GroutingDailyDetail gdd on ip.GroutingDailyDetailID=gdd.GroutingDailyDetailID where ip.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); // } //} //xuwei add begin //2019-09-17 //更新注浆日报(交坯处理) if (isSendBody) { if (productionData.IsPublicBody.ToString() != "1" || productionData.ClassesSettingID == null) productionData.ClassesSettingID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["ClassesSettingID"]); 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); } 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(); //2022-04-22 modify 冷补不改变窑车批次号 ////xuwei fix 2020-06-15 冷补修改窑车批次号 不再取原批次号 //if (productionData.ModelType != 10) //end 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," + " islengbu," + " 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," + " :islengbu," + " :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(":islengbu",productionData.IsLengBu), 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(int finishedCheckProcedureID,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, TP_PM_GroutingDailyDetail.LOGOID, (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("产品分级【重烧】必须填写返工工序", "条码", "保存"); } } if (Convert.ToInt32(productionData.GoodsLevelTypeID) == 16) //判断冷补必须有返工工序 { 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," + " islengbu," + " 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," + "finishedprocedureid" + ")" + " values" + " (:productiondataid," + " :barcode," + " :centralizedbatchno," + " :productionlineid," + " :productionlinecode," + " :productionlinename," + " :procedureid," + " :procedurecode," + " :procedurename," + " :proceduremodel," + " :modeltype," + " :piecetype," + " :isreworked," + " :nodetype," + " :ispublicbody," + " :isrefire," + " :islengbu," + " :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," + ":finishedprocedureid"; } else { sql = sql + ":checkTime," + ":finishedprocedureid"; } 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(":islengbu",productionData.IsLengBu), 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), new OracleParameter(":finishedprocedureid",finishedCheckProcedureID), }; } 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(":islengbu",productionData.IsLengBu), 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(":finishedprocedureid",finishedCheckProcedureID), }; } #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, bool isSendBody = false) { #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, "条码", "保存"); } //xuwei fix begin //2019-09-17 //更新用过条码 //交坯=4,在产=3 string barcodeStatus = isSendBody ? "4" : "3"; string updateUsedBarCode = "update TP_PM_USEDBARCODE set barcodestatus=" + barcodeStatus + " where barcode='" + inProduction.BarCode + "'"; oracleTrConn.ExecuteNonQuery(updateUsedBarCode); //xuwei 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 UpdateInProductionSpec(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," // 扫码后,返修标识清除 + " isreworkflag = '0'," + " ReworkProcedureID = :reworkProcedureID,"; #region 只有走特定返工工序时才更改重烧字段 if (inProduction.IsReFire != null) { sql = sql + " IsReFire = :isReFire,"; paras.Add(new OracleParameter(":isReFire", inProduction.IsReFire)); } #endregion #region 只有走特定返工工序时才更改重烧字段 if (inProduction.IsLengBu != null) { sql = sql + " IsLengBu = :isLengBu,"; paras.Add(new OracleParameter(":isLengBu", inProduction.IsLengBu)); } #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 更新窑炉窑车属性 //xuwei add 2020-06-15 冷补 需要更新窑车号 if (inProduction.ModelType == 10) { sql = sql + " KilnCarBatchNo = :KilnCarBatchNo,"; paras.Add(new OracleParameter(":KilnCarBatchNo", inProduction.KilnCarBatchNo)); } #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; } /// /// 修改在产数据 /// /// 连接对象 /// 在产数据实体类 /// 用户基本信息 /// 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," // 扫码后,返修标识清除 + " isreworkflag = '0'," + " 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.IsLengBu != null) { sql = sql + " IsLengBu = :isLengBu,"; paras.Add(new OracleParameter(":isLengBu", inProduction.IsLengBu)); } #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)); } //xuwei add 2020-06-15 冷补 需要更新窑车号 else if (inProduction.ModelType == 10) { sql = sql + " KilnCarBatchNo = :KilnCarBatchNo,"; paras.Add(new OracleParameter(":KilnCarBatchNo", inProduction.KilnCarBatchNo)); } 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 ServiceResultEntity AddCheckBarcode(int procedureID, ProductionDataEntity[] productionDataEntitys,DataTable bomDetailTable, SUserInfo sUserInfo) { ServiceResultEntity sre = new ServiceResultEntity(); string errMsg = ""; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { oracleTrConn.Connect(); #region 查询工序信息 //ProcedureEntity procedure = GetProcedurByID(oracleTrConn, procedureID); string sql = @"select pt.PROCEDUREID, t.PRODUCTIONLINEID, t.NODENO, pt.PROCEDURECODE, pt.PROCEDURENAME, t.PROCEDUREMODEL, t.MODELTYPE, t.NODETYPE, t.MUSTFLAG, t.COLLECTTYPE, t.PIECETYPE, t.ISSPECIALREWORK, t.ORGANIZATIONID, t.REMARKS, t.ACCOUNTID, t.VALUEFLAG, t.CREATETIME, t.CREATEUSERID, t.UPDATETIME, t.UPDATEUSERID, t.OPTIMESTAMP, t.DeliverType, t.BARCODEPRINTCOPIES, TP_PC_PRODUCTIONLINE.PRODUCTIONLINECODE, TP_PC_PRODUCTIONLINE.PRODUCTIONLINENAME, t.PROCEDUREID as finishedcheckprocedureid from Tp_PC_Procedure t left join TP_PC_PRODUCTIONLINE on TP_PC_PRODUCTIONLINE.PRODUCTIONLINEID = t.PRODUCTIONLINEID left join tp_pc_procedure pt on pt.procedureid = t.finishedcheckprocedureid where t.procedureid = :procedureID"; DataTable procedureData = oracleTrConn.GetSqlResultToDt( sql, new OracleParameter[] { new OracleParameter(":procedureID", procedureID) }); ProcedureEntity procedure = new ProcedureEntity(); if (procedureData != null && procedureData.Rows.Count > Constant.INT_IS_ZERO) { DataRow row = procedureData.Rows[0]; // 转实体 procedure = DataConvert.DataRowConvertToObject(row); } else { procedure = null; } #endregion #region 成品检验 errMsg = AddFinishCheckPDA(oracleTrConn, procedure, productionDataEntitys, bomDetailTable, sUserInfo); #endregion // 没有错误 提交事务 if (string.IsNullOrEmpty(errMsg)) { sre.Result = 1; oracleTrConn.Commit(); } } catch (Exception ex) { oracleTrConn.Rollback(); throw ex; } finally { // 释放资源 if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Disconnect(); } } return sre; } /// /// 入窑前检验 /// /// 连接对象 /// 工序 /// 生产数据集 /// 用户基本信息 /// 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().ToUpper(); #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 添加责任工序 //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的 //xuwei fix 2019-09-26 使用通用方法判定 if (IsNodeBegin(oracleTrConn, productionData.Barcode) == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin; 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().ToUpper(); // 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().ToUpper(); 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; //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的 //xuwei fix 2019-09-26 使用通用方法判定 // 2019-1016 if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { int isNodeBegin = IsNodeBegin(oracleTrConn, productionData.Barcode); if (isNodeBegin == 0) { procedure.NodeType = (int)Constant.ProcedureNodeType.Middle; } } 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 开始节点 //xuwei remove 2019-09-26 此处应该是重复判定 移除 //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的 //xuwei fix 2019-09-26 使用通用方法判定 //int isNodeBegin = IsNodeBegin(oracleTrConn, productionData.Barcode); // 2019-1016 //if (isNodeBegin == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin; 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(); //xuwei remove 2019-09-26 此处是重复判定移除 //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的 //xuwei fix 2019-09-26 使用通用方法判定 //int isNodeBegin = IsNodeBegin(oracleTrConn, productionData.Barcode); // 2019-1016 //if (isNodeBegin == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin; 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 添加责任工序 //xuwei remove 2019-09-26 此处是重复判定移除 //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的 //xuwei fix 2019-09-26 使用通用方法判定 //int isNodeBegin = IsNodeBegin(oracleTrConn, productionData.Barcode); // 2019-1016 //if (isNodeBegin == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin; // 不是开始工序时。需要添加责任工序 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 检验出缺陷 并且不是废品 修改在产产品数据 //xuwei remove 2019-09-26 此处是重复判定移除 //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的 //xuwei fix 2019-09-26 使用通用方法判定 //int isNodeBegin = IsNodeBegin(oracleTrConn, productionData.Barcode); // 2019-1016 //if (isNodeBegin == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin; 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 #region 写入检验标识 CheckFlag 用于计件 xuwei 2020-07-29 oracleTrConn.ExecuteNonQuery(@" UPDATE TP_PM_PRODUCTIONDATA SET CHECKFLAG = :CHECKFLAG WHERE PRODUCTIONDATAID = :PRODUCTIONDATAID ", new OracleParameter[] { new OracleParameter(":CHECKFLAG",productionData.CheckFlag), new OracleParameter(":PRODUCTIONDATAID",productionDataID) } ); #endregion #region 调用PLC xuwei add 2020-06-29 //成检交接 调用PLC接口 2020-06-29 xuwei if (procedure.ModelType == -4) { return PLCModuleLogic.DoPLCWorkByUser_HEGII_S3(sUserInfo, productionData.Barcode, productionData.ProcedureID, 0, productionData.PLCWeight).Message; } #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, DataTable bomDetailTable, SUserInfo sUserInfo) { string errMsg = ""; // 获得账务日期 DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo); // 本批采集的批次号 string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper(); 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; //获取成检ID(校验条码) ServiceResultEntity sre = GetProductionID(productionData.Barcode); int procedureID = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["finishedcheckprocedureid"]); #region 校验条码有效性 errMsg = CheckBarcode(oracleTrConn, 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 int isInProduction = 1; #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 0 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 0 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 "数据已经被修改,请重新进行编辑"; } isInProduction = Convert.ToInt32(returnDataset.Tables[0].Rows[0][0]); #endregion //如果原来是 次品 / 废品 xuwei modify 2019-12-13 加入 废品识别 if (productionData.OrgGoodsLevelTypeID == Constant.GoodsLevelType.Reject.GetHashCode() || productionData.OrgGoodsLevelTypeID == Constant.GoodsLevelType.Waste.GetHashCode() ) { //改为 次品 废品 xuwei modify 2019-12-13 加入废品识别 if (productionData.GoodsLevelTypeID == Constant.GoodsLevelType.Reject.GetHashCode() || productionData.GoodsLevelTypeID == Constant.GoodsLevelType.Waste.GetHashCode() ) { // 删除生产数据及相关表与报损表 errMsg = DeleteSubstandardToSubstandardByID(oracleTrConn, productionData.ProductionDataID, productionData.Barcode, sUserInfo); if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } RejectToReject = true; } //改为不是 次品 废品 xuwei modify 2019-12-13 加入废品识别 else if (productionData.GoodsLevelTypeID != Constant.GoodsLevelType.Reject.GetHashCode() || productionData.GoodsLevelTypeID != Constant.GoodsLevelType.Waste.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 //2022年2月22日10:54:32 by feiy modify 若产品分级为次品时,productionData.ProductionDefects必须有值 //暂时来解决登记是次品,但无缺陷明细的情况 if ((productionData.ProductionDefects == null || productionData.ProductionDefects.Count <= 0) && productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Reject) { return "登记是次品,必须登记缺陷"; } // 查询新插入的生产数据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;//产品分级的时候,并不标记,走过重烧第一个结点之后,更新此字段 } // 冷补 if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.LengBu) { productionData.IsLengBu = 0; } // 次品 废品 xuwei 2019-12-13 加入 废品识别 else if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Reject || productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Waste ) { //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";//干补标识 int finishedCheckProcedureID = procedure.FinishedCheckProcedureID;//成检工序ID errMsg = AddFinishCheckProductionData(finishedCheckProcedureID,oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag); 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 { if (isInProduction == 1) { 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.Begin || procedure.NodeType == (int)Constant.ProcedureNodeType.Middle || productionData.IsReFire == Constant.GoodsGrade.ReFire.GetHashCode() || productionData.IsLengBu == 1) { #region 修改在产产品数据的当前工序 if (finishedCheckProcedureID > 0 ){ 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.IsLengBu = productionData.IsLengBu; // 缺陷 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 = UpdateInProductionSpec(oracleTrConn, inProductionEntity, sUserInfo); // 执行失败 if (!string.IsNullOrEmpty(errMsg)) { return errMsg; } } else { 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.IsLengBu = productionData.IsLengBu; // 缺陷 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 #region 更新注浆明细上的冷补标识 if (productionData.IsLengBu == 1) { oracleTrConn.ExecuteNonQuery(@" UPDATE tp_pm_groutingdailydetail SET ISLENGBU = '1' WHERE BARCODE = :BARCODE ", new OracleParameter[] { new OracleParameter(":BARCODE", productionData.Barcode) }); } #endregion #region 写入检验标识 CheckFlag 用于计件 xuwei 2020-04-21 oracleTrConn.ExecuteNonQuery(@" UPDATE TP_PM_PRODUCTIONDATA SET CHECKFLAG = :CHECKFLAG WHERE PRODUCTIONDATAID = :PRODUCTIONDATAID ", new OracleParameter[] { new OracleParameter(":CHECKFLAG",productionData.CheckFlag), new OracleParameter(":PRODUCTIONDATAID",productionDataID) } ); #endregion #region bomDetail报损 if (bomDetailTable != null && bomDetailTable.Rows.Count > 0 ) { //取大件小件-》成本中心 string costcenter = string.Empty; string costcenterName = string.Empty; string sqlStrings = @"SELECT SUBSTR(GT.GOODSTYPECODE , 0,6) as GOODSTYPECODE FROM TP_PM_GROUTINGDAILYDETAIL GDD INNER JOIN TP_MST_GOODS G ON G.GOODSID = GDD.GOODSID INNER JOIN TP_MST_GOODSTYPE GT ON GT.GOODSTYPEID = G.GOODSTYPEID WHERE BARCODE = :BarCode"; OracleParameter[] parmetersSql = null; parmetersSql = new OracleParameter[] { new OracleParameter(":BarCode", OracleDbType.NVarchar2, productionData.Barcode, ParameterDirection.Input), }; DataSet returnDataset = oracleTrConn.GetSqlResultToDs(sqlStrings, parmetersSql); if (returnDataset != null && returnDataset.Tables.Count > 0 && returnDataset.Tables[0].Rows.Count > 0 ) { //大件 if (returnDataset.Tables[0].Rows[0]["GOODSTYPECODE"] +"" == "001001") { costcenter = "5000600206"; costcenterName = "成检部-一科(大件)"; } else if (returnDataset.Tables[0].Rows[0]["GOODSTYPECODE"] + "" == "001002") { //小件 costcenter = "5000600106"; costcenterName = "成检部-一科(小件)"; } } for (int i = 0; i < bomDetailTable.Rows.Count; i++) { //单报损(只插入报损表,原材料表不动) if (bomDetailTable.Rows[i]["FrmLossCheck"] + "" == "1") { #region SQL string sqlString = "insert into TP_PM_BARCODEIDNRKSCRAP(\n" + "PROCEDUREID,\n" + "SCRAPTYPE,\n" + "BARCODE,\n" + "MATNR,\n" + "IDNRK,\n" + "MEINS,\n" + "MENGE,\n" + "IDNRKNAME,\n" + "IDNRKONLYCODE,\n" + "CHARG,\n" + "LGORT,\n" + "AccountID,\n" + "CreateTime,\n" + "CreateUserID,\n" + "UpdateTime,\n" + "UpdateUserID,\n" + "COSTCENTER,\n" + "COSTCENTERNAME,\n" + "SCRAPREASON)" + " values" + " (:PROCEDUREID," + " :SCRAPTYPE," + " :BARCODE," + " :MATNR," + " :IDNRK," + " :MEINS," + " :MENGE," + " :IDNRKNAME," + " :IDNRKONLYCODE," + " :CHARG," + " :LGORT," + " :AccountID," + " SYSDATE," + " :CreateUserID," + " SYSDATE," + " :UpdateUserID," + " :COSTCENTER," + " :COSTCENTERNAME," + " :SCRAPREASON)"; #endregion #region OracleParameter OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":PROCEDUREID",procedure.ProcedureID), new OracleParameter(":SCRAPTYPE","1"), new OracleParameter(":BARCODE",productionData.Barcode), new OracleParameter(":MATNR",bomDetailTable.Rows[i]["MATNR"]+""), new OracleParameter(":IDNRK",bomDetailTable.Rows[i]["IDNRK"]+""), new OracleParameter(":MEINS",bomDetailTable.Rows[i]["MEINS"]+""), new OracleParameter(":MENGE",bomDetailTable.Rows[i]["MENGE"]+""), new OracleParameter(":IDNRKNAME",bomDetailTable.Rows[i]["DetailName"]+""), new OracleParameter(":IDNRKONLYCODE",bomDetailTable.Rows[i]["IDNRKONLYCODE"]+""), new OracleParameter(":CHARG",bomDetailTable.Rows[i]["CHARG"]+""), new OracleParameter(":LGORT",bomDetailTable.Rows[i]["LGORT"]+""), new OracleParameter(":AccountID",sUserInfo.AccountID), new OracleParameter(":CreateUserID",sUserInfo.UserID), new OracleParameter(":UpdateUserID",sUserInfo.UserID), new OracleParameter(":COSTCENTER",costcenter), new OracleParameter(":COSTCENTERNAME",costcenterName), new OracleParameter(":SCRAPREASON",bomDetailTable.Rows[i]["SCRAPREASON"]+""), }; #endregion int result = oracleTrConn.ExecuteNonQuery(sqlString, paras); } //回收(删除原材料表中对应的组件,报损表不动) else if (bomDetailTable.Rows[i]["RecoverCheck"] + "" == "1") { string sqlString = "UPDATE TP_PM_BARCODEIDNRKREL t\n" + " SET t.valueFlag = '0'\n" + " WHERE t.RELATIONID = " + bomDetailTable.Rows[i]["RELATIONID"]; int result = oracleTrConn.ExecuteNonQuery(sqlString); } //报损并换新(更新原材料表(新编码),旧编码插入报损表) else if (bomDetailTable.Rows[i]["NewCheck"] + "" == "1") { string sqlString = string.Empty; int result = 0; if (!string.IsNullOrWhiteSpace(bomDetailTable.Rows[i]["NEWIDNRKONLYCODE"]+"")) { sqlString = "UPDATE TP_PM_BARCODEIDNRKREL t\n" + " SET t.IDNRKONLYCODE = '" + bomDetailTable.Rows[i]["NEWIDNRKONLYCODE"] + "' " + " WHERE t.RELATIONID = " + bomDetailTable.Rows[i]["RELATIONID"] + ""; result = oracleTrConn.ExecuteNonQuery(sqlString); } #region SQL sqlString = "insert into TP_PM_BARCODEIDNRKSCRAP(\n" + "PROCEDUREID,\n" + "SCRAPTYPE,\n" + "BARCODE,\n" + "MATNR,\n" + "IDNRK,\n" + "MEINS,\n" + "MENGE,\n" + "IDNRKNAME,\n" + "IDNRKONLYCODE,\n" + "CHARG,\n" + "LGORT,\n" + "AccountID,\n" + "CreateTime,\n" + "CreateUserID,\n" + "UpdateTime,\n" + "UpdateUserID,\n" + "COSTCENTER,\n" + "COSTCENTERNAME,\n" + "SCRAPREASON)" + " values" + " (:PROCEDUREID," + " :SCRAPTYPE," + " :BARCODE," + " :MATNR," + " :IDNRK," + " :MEINS," + " :MENGE," + " :IDNRKNAME," + " :IDNRKONLYCODE," + " :CHARG," + " :LGORT," + " :AccountID," + " SYSDATE," + " :CreateUserID," + " SYSDATE," + " :UpdateUserID," + " :COSTCENTER," + " :COSTCENTERNAME," + " :SCRAPREASON)"; #endregion #region OracleParameter OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":PROCEDUREID",procedure.ProcedureID), new OracleParameter(":SCRAPTYPE","1"), new OracleParameter(":BARCODE",productionData.Barcode), new OracleParameter(":MATNR",bomDetailTable.Rows[i]["MATNR"]+""), new OracleParameter(":IDNRK",bomDetailTable.Rows[i]["IDNRK"]+""), new OracleParameter(":MEINS",bomDetailTable.Rows[i]["MEINS"]+""), new OracleParameter(":MENGE",bomDetailTable.Rows[i]["MENGE"]+""), new OracleParameter(":IDNRKNAME",bomDetailTable.Rows[i]["DetailName"]+""), new OracleParameter(":IDNRKONLYCODE",bomDetailTable.Rows[i]["IDNRKONLYCODE"]+""), new OracleParameter(":CHARG",bomDetailTable.Rows[i]["CHARG"]+""), new OracleParameter(":LGORT",bomDetailTable.Rows[i]["LGORT"]+""), new OracleParameter(":AccountID",sUserInfo.AccountID), new OracleParameter(":CreateUserID",sUserInfo.UserID), new OracleParameter(":UpdateUserID",sUserInfo.UserID), new OracleParameter(":COSTCENTER",costcenter), new OracleParameter(":COSTCENTERNAME",costcenterName), new OracleParameter(":SCRAPREASON",bomDetailTable.Rows[i]["SCRAPREASON"]+""), }; #endregion result += oracleTrConn.ExecuteNonQuery(sqlString, paras); } } } #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; } } #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().ToUpper(); // 条码信息 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, islengbu, 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, islengbu, 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 /// 条码 /// 返回的产品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" || ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "4") { //ErrorMessage = "产品已交坯"; 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 AddNormalWorkPieceSinglePoint(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo, int goodsID, string goodsCode, string goodsName, string groutingUserCode, int? arvGroutingDailyDetailID, bool isSendBody = false) { 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().ToUpper(); 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) { // ccc todo //if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的 if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { #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; //冷补后列新窑车批次号 xuwei add 2020-06-11 if (procedure.ModelType == 10) productionData.KilnCarBatchNo = centralizedBatchNo; 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 + "')"; //xuwei fix 2019-09-18 交坯节点判定修改 //if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)//是交坯节点,肯定不会是重烧 if (isSendBody)//是交坯节点,肯定不会是重烧 { 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; //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的 //xuwei fix 2019-09-26 使用通用方法判定 // 2019-1016 //int isNodeBegin = IsNodeBegin(oracleTrConn, productionData.Barcode); //if (isNodeBegin == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin; if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { int isNodeBegin = IsNodeBegin(oracleTrConn, productionData.Barcode); if (isNodeBegin == 0) { procedure.NodeType = (int)Constant.ProcedureNodeType.Middle; } } if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin) { //xuwei fix 2019-09-17 加入最后一个参数 isSendBody识别交坯 errMsg = AddProductionDataDeliverMud(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, out outDataSet, isSendBody); } else { //xuwei fix 2019-09-17 加入最后一个参数 isSendBody识别交坯 errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, isSendBody); } 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 //冷补后列新窑车批次号 xuwei add 2020-06-11 if (procedure.ModelType == 10) addInProductionEntity.KilnCarBatchNo = centralizedBatchNo; // 生产工号 addInProductionEntity.UserID = workUserID; // 执行添加 //xuwei fix 2019-09-17 加入最后一个参数 isSendBody识别交坯 errMsg = AddInProduction(oracleTrConn, addInProductionEntity, sUserInfo, outDataSet, isSendBody); // 执行失败 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 //冷补后列新窑车批次号 xuwei add 2020-06-11 if (procedure.ModelType == 10) addInProductionEntity.KilnCarBatchNo = centralizedBatchNo; // 执行修改 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; } } #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 { // chenxy 2019-10-02 半检返修 IsReworkFlag=2 //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 #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 #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) { // chenxy 2019-10-02 半检返修 IsReworkFlag=2 //if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1") if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() != "0") { 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" + // chenxy 2019-10-02 半检返修 IsReworkFlag=2 //" AND p.IsReworkFlag <> '1' AND p.InScrapFlag <> '1' \n" + " AND p.IsReworkFlag = '0' AND p.InScrapFlag = '0' \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 删除在产数据 // chenxy 2019-10-02 半检返修 IsReworkFlag=2 //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'"; sql = @" delete from tp_pm_inproduction p where p.barcode =:barcode AND p.modeltype not in (1,2,3,6) AND p.IsReworkFlag = '0' AND p.InScrapFlag = '0'"; 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; //lsq 20210723 已注浆非产成品没有商标可以变更商标 //begin object pdid = null; //end 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) // }); //lsq 20210723 已注浆非产成品没有商标可以变更商标 //begin //sql = @"select g.logoid, f.fhuserid from tp_pm_groutingdailydetail g // left join tp_pm_finishedproduct f on g.barcode = f.barcode // where g.barcode=:barcode"; sql = @"select g.logoid,g.GROUTINGDAILYDETAILID,f.fhuserid from tp_pm_groutingdailydetail g left join tp_pm_finishedproduct f on g.barcode = f.barcode where g.barcode=:barcode"; //end DataTable dt = oracleTrConn.GetSqlResultToDt(sql, new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }); if (dt != null && dt.Rows.Count > 0) { oldLogoID = dt.Rows[0]["logoid"]; object fhuserid = dt.Rows[0]["fhuserid"]; //lsq 20210723 已注浆非产成品没有商标可以变更商标 //begin pdid = dt.Rows[0]["GROUTINGDAILYDETAILID"]; //if (oldLogoID == null || oldLogoID == DBNull.Value) if (pdid == null || pdid == DBNull.Value) //end { // 条码不存在 ——> 该条码未注浆 lsq 20210723 return -2; } if (fhuserid != null && fhuserid != DBNull.Value) { // "已交接的产品不能变更商标"; return -3; } } // 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 SaveBarCodeLogoAndGlazetype(string barcode, int logoid, int glazetypeid, 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; string sql = "select g.groutingdailydetailid, g.logoid, g.glazetypeid, t.PROCEDUREID from tp_pm_groutingdailydetail g \n" + " left join tp_pm_inproduction t on t.barcode = g.barcode\n" + "where g.barcode = :barcode"; Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.NVarchar2, barcode,ParameterDirection.Input), }; DataTable dt = oracleTrConn.GetSqlResultToDt(sql, Paras); if (dt == null || dt.Rows.Count == 0) { return -2; } // 釉料变更履历 sql = "insert into TP_PM_GlazetypeRecord\n" + //"values\n" + xuwei update 2020-01-02 " (GROUTINGDAILYDETAILID\n" + " ,OldGlazetypeid\n" + " ,NewGlazetypeid\n" + " ,ProcedureID\n" + " ,Remarks\n" + " ,AccountID\n" + " ,CreateUserID)\n" + "values\n" + " (:GROUTINGDAILYDETAILID\n" + " ,:OldGlazetypeid\n" + " ,:NewGlazetypeid\n" + " ,:ProcedureID\n" + " ,:Remarks\n" + " ,:AccountID\n" + " ,:CreateUserID)"; Paras = new OracleParameter[] { new OracleParameter(":GROUTINGDAILYDETAILID",OracleDbType.Int32, dt.Rows[0]["GROUTINGDAILYDETAILID"],ParameterDirection.Input), new OracleParameter(":OldGlazetypeid",OracleDbType.Int32, dt.Rows[0]["glazetypeid"],ParameterDirection.Input), new OracleParameter(":NewGlazetypeid",OracleDbType.Int32, glazetypeid,ParameterDirection.Input), new OracleParameter(":ProcedureID",OracleDbType.Int32, dt.Rows[0]["PROCEDUREID"],ParameterDirection.Input), new OracleParameter(":Remarks",OracleDbType.NVarchar2, null,ParameterDirection.Input), new OracleParameter(":AccountID",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input), new OracleParameter(":CreateUserID",OracleDbType.Int32, sUserInfo.UserID,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, dt.Rows[0]["LOGOID"],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); // 1.更新注浆明细 sql = "update tp_pm_groutingdailydetail set logoid=:logoid, glazetypeid =:glazetypeid, updateuserid=:updateuserid where barcode=:barcode"; Paras = new OracleParameter[] { new OracleParameter(":logoid",OracleDbType.Int32, logoid,ParameterDirection.Input), new OracleParameter(":glazetypeid",OracleDbType.Int32, glazetypeid,ParameterDirection.Input), new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras); // 1.更新在产 sql = @"update TP_PM_INPRODUCTION set logoid=:logoid, --glazetypeid =:glazetypeid, updateuserid=:updateuserid where barcode=:barcode"; Paras = new OracleParameter[] { new OracleParameter(":logoid",OracleDbType.Int32, logoid,ParameterDirection.Input), //new OracleParameter(":glazetypeid",OracleDbType.Int32, // glazetypeid,ParameterDirection.Input), new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); oracleTrConn.Commit(); } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); } throw ex; } finally { oracleTrConn.Disconnect(); } return returnRows; } /// /// 设置条码商标 釉料 /// /// public static int SaveBarCodesLogoAndGlazetype(string barcodesstr, int logoid, int glazetypeid, int procedureID, SUserInfo sUserInfo) { int returnRows = 0; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { OracleParameter[] Paras = null; string sql = "select g.groutingdailydetailid, g.logoid, g.glazetypeid, t.PROCEDUREID from tp_pm_groutingdailydetail g \n" + " left join tp_pm_inproduction t on t.barcode = g.barcode\n" + "where g.barcode = :barcode"; string sql0 = "select g.groutingdailydetailid, g.logoid, g.glazetypeid from tp_pm_groutingdailydetail g \n" + "where g.barcode = :barcode"; // 釉料变更履历 string sql1 = "insert into TP_PM_GlazetypeRecord\n" + //"values\n" + xuwei update 2020-01-02 " (GROUTINGDAILYDETAILID\n" + " ,OldGlazetypeid\n" + " ,NewGlazetypeid\n" + " ,ProcedureID\n" + " ,Remarks\n" + " ,AccountID\n" + " ,CreateUserID)\n" + "values\n" + " (:GROUTINGDAILYDETAILID\n" + " ,:OldGlazetypeid\n" + " ,:NewGlazetypeid\n" + " ,:ProcedureID\n" + " ,:Remarks\n" + " ,:AccountID\n" + " ,:CreateUserID)"; // 变更履历 string sqllogo = "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)"; string sql2 = "update tp_pm_groutingdailydetail set logoid=:logoid, glazetypeid =:glazetypeid, updateuserid=:updateuserid where barcode=:barcode"; // 1.更新在产 string sqlin = @"update TP_PM_INPRODUCTION set logoid=:logoid, --glazetypeid =:glazetypeid, updateuserid=:updateuserid where barcode=:barcode"; //xuwei add 2020-01-02 string[] barcodes = barcodesstr.Split(','); foreach (string barcode in barcodes) { Paras = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.NVarchar2, barcode,ParameterDirection.Input), }; DataTable dt = null; if (procedureID > 0) { dt = oracleTrConn.GetSqlResultToDt(sql0, Paras); } else { dt = oracleTrConn.GetSqlResultToDt(sql, Paras); } if (dt == null || dt.Rows.Count == 0) { //continue; return -2; } Paras = new OracleParameter[] { new OracleParameter(":GROUTINGDAILYDETAILID",OracleDbType.Int32, dt.Rows[0]["GROUTINGDAILYDETAILID"],ParameterDirection.Input), new OracleParameter(":OldGlazetypeid",OracleDbType.Int32, dt.Rows[0]["glazetypeid"],ParameterDirection.Input), new OracleParameter(":NewGlazetypeid",OracleDbType.Int32, glazetypeid,ParameterDirection.Input), new OracleParameter(":ProcedureID",OracleDbType.Int32, (procedureID > 0 ? procedureID : dt.Rows[0]["PROCEDUREID"]),ParameterDirection.Input), new OracleParameter(":Remarks",OracleDbType.NVarchar2, null,ParameterDirection.Input), new OracleParameter(":AccountID",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input), new OracleParameter(":CreateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), }; oracleTrConn.ExecuteNonQuery(sql1, Paras); // 商标履历 Paras = new OracleParameter[] { new OracleParameter(":OLDLOGOID",OracleDbType.Int32, dt.Rows[0]["LOGOID"],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(sqllogo, Paras); // 1.更新注浆明细 Paras = new OracleParameter[] { new OracleParameter(":logoid",OracleDbType.Int32, logoid,ParameterDirection.Input), new OracleParameter(":glazetypeid",OracleDbType.Int32, glazetypeid,ParameterDirection.Input), new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; returnRows += oracleTrConn.ExecuteNonQuery(sql2, Paras); // 1.更新在产 Paras = new OracleParameter[] { new OracleParameter(":logoid",OracleDbType.Int32, logoid,ParameterDirection.Input), //new OracleParameter(":glazetypeid",OracleDbType.Int32, // glazetypeid,ParameterDirection.Input), new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input), new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input) }; returnRows = oracleTrConn.ExecuteNonQuery(sqlin, Paras); } oracleTrConn.Commit(); } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); } throw ex; } finally { oracleTrConn.Disconnect(); } 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 = ""; //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的 //xuwei fix 2019-09-26 使用通用方法判定 // 2019-1016 //int isNodeBegin = IsNodeBegin(oracleTrConn, productionData.Barcode); //if (isNodeBegin == 1) productionData.NodeType = (int)Constant.ProcedureNodeType.Begin; if (productionData.NodeType == (int)Constant.ProcedureNodeType.Begin) { int isNodeBegin = IsNodeBegin(oracleTrConn, productionData.Barcode); if (isNodeBegin == 0) { productionData.NodeType = (int)Constant.ProcedureNodeType.Middle; } } 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," + " islengbu," + " 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," + " :islengbu," + " :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(":islengbu",productionData.IsLengBu), 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().ToUpper(); // 条码 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); // 注浆明细 产品等级 sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=13,updateuserid=:updateuserid where barcode=:barcode"; OracleParameter[] oracleParameters = new OracleParameter[] { new OracleParameter(":accountid", sUserInfo.AccountID), new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":updateuserid",sUserInfo.UserID), }; oracleTrConn.ExecuteNonQuery(sql, oracleParameters); } else { errMsg = AddSemiCheckData(oracleTrConn, entity, sUserInfo); if (entity.SemiCheckType == "1") { // 注浆明细 产品等级 sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=2,updateuserid=:updateuserid where barcode=:barcode"; OracleParameter[] oracleParameters = new OracleParameter[] { new OracleParameter(":accountid", sUserInfo.AccountID), new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":updateuserid",sUserInfo.UserID), }; oracleTrConn.ExecuteNonQuery(sql, oracleParameters); } else { // 注浆明细 产品等级 sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=1,updateuserid=:updateuserid where barcode=:barcode"; OracleParameter[] oracleParameters = new OracleParameter[] { new OracleParameter(":accountid", sUserInfo.AccountID), new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":updateuserid",sUserInfo.UserID), }; oracleTrConn.ExecuteNonQuery(sql, oracleParameters); } } 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 GoodsLevelTypeID=2,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); // 注浆明细 产品等级 sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=13,updateuserid=:updateuserid where barcode=:barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":accountid", sUserInfo.AccountID), new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":updateuserid",sUserInfo.UserID), }; 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 GoodsLevelTypeID=2,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); // 注浆明细 产品等级 sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=2,updateuserid=:updateuserid where barcode=:barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":accountid", sUserInfo.AccountID), new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":updateuserid",sUserInfo.UserID), }; result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters); } else if (entity.SemiCheckType == "0") //正常 { sql = @"update TP_PM_InProduction set GoodsLevelTypeID=1,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); // 注浆明细 产品等级 sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=1,updateuserid=:updateuserid where barcode=:barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":accountid", sUserInfo.AccountID), new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":updateuserid",sUserInfo.UserID), }; 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); // 注浆明细 产品等级 sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=13,updateuserid=:updateuserid where barcode=:barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":accountid", sUserInfo.AccountID), new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":updateuserid",sUserInfo.UserID), }; 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, 2, 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); // 注浆明细 产品等级 sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=2,updateuserid=:updateuserid where barcode=:barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":accountid", sUserInfo.AccountID), new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":updateuserid",sUserInfo.UserID), }; result = oracleTrConn.ExecuteNonQuery(sql, 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, 1, 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); // 注浆明细 产品等级 sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=1,updateuserid=:updateuserid where barcode=:barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":accountid", sUserInfo.AccountID), new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":updateuserid",sUserInfo.UserID), }; result = oracleTrConn.ExecuteNonQuery(sql, 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), }; // 重复登记的问题 for update string sql = @" select InScrapFlag, KilnCarID, KilnCarName, IsReworkFlag, SemiCheckID from TP_PM_InProduction where barcode=:barcode for update "; 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() + "]"; ; } // chenxy 2019-10-02 半检返修 IsReworkFlag=2 if (dsResult.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1") { return "条码[" + barcode + "]已经半检返工中"; } if (dsResult.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "2") { 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), }; // 重复登记的问题 for update string sql = @" select InScrapFlag, KilnCarID, KilnCarName, IsReworkFlag, SemiCheckID from TP_PM_InProduction where barcode=:barcode for update "; 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() + "]"; ; } // chenxy 2019-10-02 半检返修 IsReworkFlag=2 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), }; // 重复登记的问题 for update string sql = @" select 1 from TP_PM_InProductionTrash where barcode=:barcode and GoodsLevelTypeID=13 for update"; 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); // 注浆明细 产品等级 sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=14,updateuserid=:updateuserid where barcode=:barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":accountid", sUserInfo.AccountID), 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,ISREWORKFLAG, 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,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.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 GoodsLevelTypeID=1, 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); // 注浆明细 产品等级 sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=1,updateuserid=:updateuserid where barcode=:barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":accountid", sUserInfo.AccountID), 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 GoodsLevelTypeID=2, 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); // 注浆明细 产品等级 sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=2,updateuserid=:updateuserid where barcode=:barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":accountid", sUserInfo.AccountID), new OracleParameter(":barcode",entity.BarCode), new OracleParameter(":updateuserid",sUserInfo.UserID), }; 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,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_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 GoodsLevelTypeID=2,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); // 注浆明细 产品等级 sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=2,updateuserid=:updateuserid where barcode=:barcode"; oracleParameters = new OracleParameter[] { new OracleParameter(":accountid", sUserInfo.AccountID), 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() + "]"; ; } // chenxy 2019-10-02 半检返修 IsReworkFlag=2 if (dsResult.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1") { return "条码[" + barcode + "]是半检返工状态"; } if (dsResult.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "2") { 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, DisplayNo, CreateTime, CreateUserID, UpdateTime, UpdateUserID ) Values ( :OrderID, :OrderNo, :OrderDate, :Remarks, :AccountID, :ValueFlag, :DisplayNo, 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(":DisplayNo",OracleDbType.Int32,order.DisplayNo,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); order.OrderID = newOrderID; } else { sql = @"Update TP_PM_Order set OrderNo=:OrderNo, OrderDate=:OrderDate, Remarks=:Remarks, ValueFlag=:ValueFlag, DisplayNo=:DisplayNo, 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(":DisplayNo",OracleDbType.Int32,order.DisplayNo,ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), }; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); } #endregion #region 保存订单明细 if (order.OrderDetail != null) { // 删除明细 sql = "DELETE FROM tp_pm_orderdetail od WHERE od.orderid = :orderid"; Paras = new OracleParameter[] { new OracleParameter(":orderid", order.OrderID) }; returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras); // 新建明细 sql = "INSERT INTO tp_pm_orderdetail\n" + " (orderid\n" + " ,materialcode\n" + " ,accountid\n" + " ,createuserid)\n" + "VALUES\n" + " (:orderid\n" + " ,:materialcode\n" + " ,:accountid\n" + " ,:createuserid)"; foreach (DataRow row in order.OrderDetail.Rows) { Paras = new OracleParameter[] { new OracleParameter(":orderid", order.OrderID), new OracleParameter(":materialcode", (row["materialcode"]+"").ToUpper().Trim()), new OracleParameter(":createuserid",sUserInfo.UserID), new OracleParameter(":accountid",sUserInfo.AccountID) }; 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, string sapName = "") { ServiceResultEntity sre = new ServiceResultEntity(); string logid_bg = "0"; OracleParameter[] Paras = null; // 条码串 string fifter = " AND (bar.barcode = '"; foreach (DataRow row in dtData.Rows) { fifter += row["barcode"] + "' OR bar.barcode = '"; } fifter = fifter.Substring(0, fifter.Length - 18) + ")"; IDBTransaction oracleTrConn2 = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { #region 判断订单是否有明细 DataTable dtMaterialcode = null; string sql = "SELECT COUNT(1) AS detailcount\n" + " FROM tp_pm_orderdetail od\n" + " WHERE od.orderid = :orderid and od.valueflag = '1'"; Paras = new OracleParameter[] { new OracleParameter(":orderid", orderid) }; bool isExistsDetail = true; object detailcount = oracleTrConn2.GetSqlResultToObj(sql, Paras); if (detailcount == null || detailcount == DBNull.Value || Convert.ToInt32(detailcount) == 0) { isExistsDetail = false; } #endregion for (int i = 0; i < dtData.Rows.Count; i++) { if (isExistsDetail) { #region 校验产品是否在订单里 sql = "SELECT gdd.materialcode\n" + " ,(select od.materialcode from tp_pm_orderdetail od where od.orderid = :orderid AND od.valueflag = '1' and gdd.materialcode = od.materialcode) " + " AS ordermaterialcode\n" + " FROM tp_pm_groutingdailydetail gdd\n" + " WHERE gdd.barcode = :barcode"; Paras = new OracleParameter[] { new OracleParameter(":orderid", orderid), new OracleParameter(":barcode", dtData.Rows[i]["barcode"].ToString()) }; dtMaterialcode = oracleTrConn2.GetSqlResultToDt(sql, Paras); if (dtMaterialcode == null || dtMaterialcode.Rows.Count == 0) { sre.Result = -2; sre.Message = $"当前产品条码{dtData.Rows[i]["barcode"]}不存在"; return sre; } if (string.IsNullOrWhiteSpace(dtMaterialcode.Rows[0]["materialcode"] + "")) { sre.Result = -2; sre.Message = $"当前产品条码{dtData.Rows[i]["barcode"]}没有物料编码,不能上传数据"; return sre; } if (string.IsNullOrWhiteSpace(dtMaterialcode.Rows[0]["ordermaterialcode"] + "")) { sre.Result = -2; sre.Message = "此订单不包含【" + dtMaterialcode.Rows[0]["materialcode"] + "】物料,不能上传数据"; return sre; } #endregion } #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), }; DataSet ds = oracleTrConn2.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)) { sre.Result = -2; //已交接,不能再次进行交接 sre.Message = "此产品【" + dtData.Rows[i]["barcode"].ToString() + "】已交接,不能再次进行交接"; return sre; } #endregion } else { #region 不是产成品 sre.Result = -1; //不是产成品 sre.Message = "此产品【" + dtData.Rows[i]["barcode"].ToString() + "】不是产成品"; return sre; #endregion } #endregion } sql = @" SELECT COUNT(DISTINCT FINISHEDLOADBATCHNO) CC FROM TP_PM_FINISHEDPRODUCT BAR WHERE 1 = 1 " + fifter; string cc = oracleTrConn2.GetSqlResultToStr(sql); if (!"1".Equals(cc)) { sre.Result = -2; sre.Message = "不允许多板一起交接"; return sre; } sql = @" SELECT DISTINCT BGLOGID FROM TP_PM_FINISHEDPRODUCT BAR WHERE 1 = 1 " + fifter; string currentBGlogid = oracleTrConn2.GetSqlResultToStr(sql); if (string.IsNullOrEmpty(currentBGlogid)) { logid_bg = oracleTrConn2.GetSqlResultToStr("select SEQ_TSAP_DATALOG_BG.Nextval from dual"); sql = @" UPDATE TP_PM_FINISHEDPRODUCT BAR SET BAR.BGLOGIDCX = NULL ,BAR.BGLOGID = " + logid_bg + @" WHERE 1 = 1 " + fifter; int r2 = oracleTrConn2.ExecuteNonQuery(sql); } else { logid_bg = currentBGlogid; } oracleTrConn2.Commit(); oracleTrConn2.Disconnect(); } catch (Exception ex) { throw ex; } IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { #region 产成品交接 if (dtData == null || dtData.Rows.Count == 0) { sre.Result = -2; sre.Message = "条码信息不能为空"; return sre; } string sql = string.Empty; DataSet ds = null; 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(); //} // 本批交接的批次号 #region 判断订单是否有明细 string fhBatchNo = System.Guid.NewGuid().ToString().ToUpper(); DataTable dtMaterialcode = null; sql = "SELECT COUNT(1) AS detailcount\n" + " FROM tp_pm_orderdetail od\n" + " WHERE od.orderid = :orderid and od.valueflag = '1'"; Paras = new OracleParameter[] { new OracleParameter(":orderid", orderid) }; bool isExistsDetail = true; object detailcount = oracleTrConn.GetSqlResultToObj(sql, Paras); if (detailcount == null || detailcount == DBNull.Value || Convert.ToInt32(detailcount) == 0) { isExistsDetail = false; } #endregion for (int i = 0; i < dtData.Rows.Count; i++) { if (isExistsDetail) { #region 校验产品是否在订单里 //sql = "SELECT gdd.materialcode\n" + //" ,od.materialcode AS ordermaterialcode\n" + //" FROM tp_pm_groutingdailydetail gdd\n" + //" LEFT JOIN tp_pm_orderdetail od\n" + //" ON gdd.materialcode = od.materialcode\n" + //" AND od.orderid = :orderid\n" + //" AND od.valueflag = '1'\n" + //" WHERE gdd.barcode = :barcode"; sql = "SELECT gdd.materialcode\n" + " ,(select od.materialcode from tp_pm_orderdetail od where od.orderid = :orderid AND od.valueflag = '1' and gdd.materialcode = od.materialcode) " + " AS ordermaterialcode\n" + " FROM tp_pm_groutingdailydetail gdd\n" + " WHERE gdd.barcode = :barcode"; Paras = new OracleParameter[] { new OracleParameter(":orderid", orderid), new OracleParameter(":barcode", dtData.Rows[i]["barcode"].ToString()) }; dtMaterialcode = oracleTrConn.GetSqlResultToDt(sql, Paras); if (dtMaterialcode == null || dtMaterialcode.Rows.Count == 0) { sre.Result = -2; sre.Message = $"当前产品条码{dtData.Rows[i]["barcode"]}不存在"; return sre; } if (string.IsNullOrWhiteSpace(dtMaterialcode.Rows[0]["materialcode"] + "")) { sre.Result = -2; sre.Message = $"当前产品条码{dtData.Rows[i]["barcode"]}没有物料编码,不能上传数据"; return sre; } if (string.IsNullOrWhiteSpace(dtMaterialcode.Rows[0]["ordermaterialcode"] + "")) { sre.Result = -2; sre.Message = "此订单不包含【" + dtMaterialcode.Rows[0]["materialcode"] + "】物料,不能上传数据"; return sre; } #endregion } #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)) { sre.Result = -2; //已交接,不能再次进行交接 sre.Message = "此产品【" + dtData.Rows[i]["barcode"].ToString() + "】已交接,不能再次进行交接"; return sre; } #endregion } else { #region 不是产成品 sre.Result = -1; //不是产成品 sre.Message = "此产品【" + dtData.Rows[i]["barcode"].ToString() + "】不是产成品"; return sre; #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) { sre.Result = -3; sre.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) { sre.Result = -4; sre.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】的型号【" + dtData.Rows[0]["GoodsModel"] + "】与此批次型号【" + GoodsModel + "】不同,不能进行该操作。 "; isError = true; break; } } #endregion #region 产品列表是否大于限制条数 if (PlateLimitNum > 0) { if (dtData.Rows.Count > PlateLimitNum) { sre.Result = -5; sre.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 } #endregion #region 同步SAP #region 同步日志 object isExists; string sqlString = string.Empty; OracleParameter[] oracleParameter = null; int r = 0; // 条码串 //string fifter = " AND (bar.barcode = '"; //foreach (DataRow row in dtData.Rows) //{ // fifter += row["barcode"] + "' OR bar.barcode = '"; //} //fifter = fifter.Substring(0, fifter.Length - 18) + ")"; //sqlString = "SELECT 1\n" + //" FROM tp_pm_groutingdailydetail bar\n" + //" WHERE bar.issync = '1'\n" + fifter; //object isExists = oracleTrConn.GetSqlResultToObj(sqlString, oracleParameter); //if (isExists != null) //{ // sre.Result = -2; // sre.Message = "当前产品已经同步过,不能重复同步。"; // return sre; //} DateTime date = DateTime.Now; string yyyymmdd = date.ToString("yyyyMMdd"); sqlString = "select workcode from tp_mst_account where rownum = 1"; string workcode = oracleTrConn.GetSqlResultToStr(sqlString); //DateTime datebegin = date.Date; //DateTime dateend = date.Date.AddDays(1); //sqlString = //"SELECT :yyyymmdd AS yyyymmdd\n" + //" ,SYSDATE AS createtime\n" + //" ,tt.goodscode\n" + //" ,tt.sapcode\n" + //" ,tt.usercode\n" + //" ,tt.ordercode\n" + //" ,tt.orderitem\n" + //" ,tt.zscs\n" + //" ,to_char(tt.outputnum) AS outputnum\n" + //" ,to_char(tt.recoverynum) AS recoverynum\n" + //" FROM (SELECT t.goodscode\n" + //" ,t.sapcode\n" + //" ,t.usercode\n" + //" ,t.ordercode\n" + //" ,t.orderitem\n" + //" ,t.zscs\n" + //" ,SUM(decode(t.recyclingflag, '1', 0, decode(t.datatype, 51, 1, -1))) outputnum\n" + //" ,SUM(decode(t.recyclingflag, '0', 0, decode(t.datatype, 51, 1, -1))) recoverynum\n" + //" FROM (SELECT gh.goodscode\n" + //" ,gh.sapcode\n" + //" ,u.usercode\n" + //" ,o.orderno\n" + //" ,bar.recyclingflag\n" + //" ,gh.datatype\n" + //" ,'' zscs\n" + ////" ,g.goods_line_code zscs\n" + //" ,CASE\n" + //" WHEN o.orderid IS NULL\n" + //" OR o.orderno LIKE 'HEGII%' THEN\n" + //" ' '\n" + //" WHEN instr(o.orderno, '/') = 0 THEN\n" + //" to_char(o.orderno)\n" + //" ELSE\n" + //" to_char(substr(o.orderno, 1, instr(o.orderno, '/') - 1))\n" + //" END ordercode -- 销售凭证\n" + //" ,CASE\n" + //" WHEN o.orderid IS NULL\n" + //" OR o.orderno LIKE 'HEGII%'\n" + //" OR instr(o.orderno, '/') = 0 THEN\n" + //" '0'\n" + //" WHEN instr(o.orderno, '#') = 0 THEN\n" + //" to_char(substr(o.orderno, instr(o.orderno, '/') + 1))\n" + //" ELSE\n" + //" to_char(substr(o.orderno\n" + //" ,instr(o.orderno, '/') + 1\n" + //" ,instr(o.orderno, '#') - instr(o.orderno, '/') - 1))\n" + //" END orderitem -- 销售凭证项目\n" + //" FROM (SELECT gch.goodscode\n" + //" ,gch.sapcode\n" + //" ,decode(gch.datatype, 53, 51, gch.datatype) datatype\n" + //" ,gch.userid\n" + //" ,gch.groutingdailydetailid\n" + //" ,gch.otherid\n" + //" FROM tp_pm_goodschangehistory gch\n" + //" WHERE gch.datatype IN (51, 52, 53)\n" + //" UNION ALL\n" + //" SELECT gch.goodscode\n" + //" ,gch.sapcode\n" + //" ,52 datatype\n" + //" ,gch.userid\n" + //" ,gch.groutingdailydetailid\n" + //" ,gch.goodsidafter\n" + //" FROM tp_pm_goodschangehistory gch\n" + //" WHERE gch.datatype = 53) gh\n" + //" INNER JOIN tp_mst_user u\n" + //" ON u.userid = gh.userid\n" + //" INNER JOIN tp_pm_groutingdailydetail bar\n" + //" ON bar.groutingdailydetailid = gh.groutingdailydetailid\n" + fifter + ////" AND bar.barcode IN (" + fifter + ")\n" + //" INNER JOIN tp_mst_goods g\n" + //" ON g.goodsid = bar.goodsid\n" + //" LEFT JOIN tp_pm_order o\n" + //" ON o.orderid = gh.otherid) t\n" + //" GROUP BY t.goodscode\n" + //" ,t.sapcode\n" + //" ,t.usercode\n" + //" ,t.ordercode\n" + //" ,t.orderitem,t.zscs) tt\n" + //" WHERE tt.outputnum <> 0\n" + //" OR tt.recoverynum <> 0\n" + //" ORDER BY tt.goodscode\n" + //" ,tt.sapcode\n" + //" ,tt.usercode\n" + //" ,tt.ordercode\n" + //" ,tt.orderitem,tt.zscs"; sqlString = "SELECT :yyyymmdd AS yyyymmdd\n" + " ,SYSDATE AS createtime\n" + " ,tt.goodscode\n" + " ,tt.sapcode\n" + " ,tt.usercode\n" + " ,tt.ordercode\n" + " ,tt.orderitem\n" + " ,tt.testmouldflag\n" + " ,tt.zscs\n" + " ,to_char(tt.outputnum) AS outputnum\n" + " ,to_char(tt.recoverynum) AS recoverynum\n" + " FROM (SELECT t.goodscode\n" + " ,t.sapcode\n" + " ,t.usercode\n" + " ,t.ordercode\n" + " ,t.orderitem\n" + " ,t.testmouldflag\n" + " ,t.zscs\n" + //" ,SUM(decode(t.recyclingflag, '1', 0, decode(t.datatype, 51, 1, -1))) outputnum\n" + //" ,SUM(decode(t.recyclingflag, '0', 0, decode(t.datatype, 51, 1, -1))) recoverynum\n" + " ,SUM(decode(t.recyclingflag, '1', 0, 1)) outputnum\n" + " ,SUM(decode(t.recyclingflag, '0', 0, 1)) recoverynum\n" + " FROM (SELECT bar.goodscode\n" + //" ,gh.sapcode\n" + //" ,u.usercode\n" + " ,bar.materialcode sapcode\n" + " ,gh.fhusercode usercode\n" + " ,o.orderno\n" + " ,bar.recyclingflag\n" + //" ,gh.datatype\n" + //" ,'' zscs\n" + //" ,case when g.goods_line_type = 1 or gl.highpressureflag = '1' then 'G' else 'L' end zscs\n" + " ,bar.testmouldflag" + " ,decode(bar.testmouldflag,'0', '', decode(g.goods_line_code,'G','A','M','A','L','B','')) as zscs\n" + " ,CASE\n" + " WHEN o.orderid IS NULL\n" + " OR o.orderno LIKE 'HEGII%' THEN\n" + " ' '\n" + " WHEN instr(o.orderno, '/') = 0 THEN\n" + " to_char(o.orderno)\n" + " ELSE\n" + " to_char(substr(o.orderno, 1, instr(o.orderno, '/') - 1))\n" + " END ordercode -- 销售凭证\n" + " ,CASE\n" + " WHEN o.orderid IS NULL\n" + " OR o.orderno LIKE 'HEGII%'\n" + " OR instr(o.orderno, '/') = 0 THEN\n" + " '0'\n" + " WHEN instr(o.orderno, '#') = 0 THEN\n" + " to_char(substr(o.orderno, instr(o.orderno, '/') + 1))\n" + " ELSE\n" + " to_char(substr(o.orderno\n" + " ,instr(o.orderno, '/') + 1\n" + " ,instr(o.orderno, '#') - instr(o.orderno, '/') - 1))\n" + " END orderitem -- 销售凭证项目\n" + " FROM tp_pm_groutingdailydetail bar\n" + //" INNER JOIN tp_mst_user u\n" + //" ON u.userid = gh.userid\n" + " INNER JOIN tp_pm_finishedproduct gh\n" + " ON bar.groutingdailydetailid = gh.groutingdailydetailid\n" + //" AND bar.barcode IN (" + fifter + ")\n" + //" INNER JOIN tp_pc_groutingline gl\n" + //" ON gl.groutinglineid = bar.groutinglineid\n" + " INNER JOIN tp_mst_goods g\n" + " ON g.goodsid = bar.goodsid\n" + " LEFT JOIN tp_pm_order o\n" + " ON o.orderid = gh.fhorderid where 1=1 " + fifter + ") t\n" + " GROUP BY t.goodscode\n" + " ,t.sapcode\n" + " ,t.usercode\n" + " ,t.ordercode\n" + " ,t.orderitem,t.testmouldflag,t.zscs) tt\n" + " WHERE tt.outputnum <> 0\n" + " OR tt.recoverynum <> 0\n" + " ORDER BY tt.goodscode\n" + " ,tt.sapcode\n" + " ,tt.usercode\n" + " ,tt.ordercode\n" + " ,tt.orderitem,tt.zscs"; oracleParameter = new OracleParameter[] { new OracleParameter(":yyyymmdd", yyyymmdd) }; DataTable workData = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter); // 同步日志ID string logid = oracleTrConn.GetSqlResultToStr("select SEQ_SAP_HEGII_DataLog_ID.Nextval from dual"); //string msg = "data:" + datebegin.ToString("yyyyMMdd-HHmm") + "~" + // dateend.ToString("yyyyMMdd-HHmm"); string msg = $"整板条码[{logid}]:" + dtData.Rows[0]["barcode"]; sqlString = "insert into tsap_hegii_datalog\n" + " (LogID\n" + " ,LogType\n" + " ,BeginTime\n" + " ,YYYYMMDD\n" + " ,WorkCode\n" + " ,DataCode\n" + " ,DataStuts\n" + " ,DataMSG\n" + " ,CreateUserID\n" + " ,DataLogID)\n" + "values\n" + " (:LogID\n" + " ,'2'\n" + " ,sysdate\n" + " ,:YYYYMMDD\n" + " ,:WorkCode\n" + " ,'60'\n" + " ,'S'\n" + " ,:DataMSG\n" + " ,:CreateUserID\n" + " ,:LogID)"; oracleParameter = new OracleParameter[] { new OracleParameter(":LogID",OracleDbType.Int32, logid, ParameterDirection.Input), new OracleParameter(":CreateUserID",OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input), new OracleParameter(":YYYYMMDD",OracleDbType.Varchar2, yyyymmdd, ParameterDirection.Input), new OracleParameter(":WorkCode",OracleDbType.Varchar2, workcode, ParameterDirection.Input), new OracleParameter(":DataMSG",OracleDbType.Varchar2, msg, ParameterDirection.Input), }; r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); #endregion #region 同步条码明细 sqlString = "INSERT INTO tsap_hegii_finishedproduct\n" + " (yyyymmdd\n" + " ,workcode\n" + " ,barcode\n" + " ,outcode\n" + " ,goodscode\n" + " ,sapcode\n" + " ,sapflbatchno\n" + " ,sapfhundoflag\n" + " ,ordercode\n" + " ,orderitem, LOGID\n" + " ,securitycode,ZTYPE)\n" + " SELECT :yyyymmdd\n" + " ,:workcode\n" + " ,bar.barcode\n" + " ,nvl(gdd.outlabelcode, (g.materialcode || :workcode || gdd.onlycode))\n" + " ,gdd.goodscode\n" + " ,nvl(gdd.materialcode, nvl(g.materialcode, g.goodscode))\n" + " ,nvl(bar.finishedloadbatchno, bar.fhbatchno)\n" + //" ,decode(gdd.sapfhundoflag, '1', 'X', ' ')\n" + " ,' '\n" + " ,CASE\n" + " WHEN o.orderid IS NULL\n" + " OR o.orderno LIKE 'HEGII%' THEN\n" + " NULL\n" + " WHEN instr(o.orderno, '/') = 0 THEN\n" + " to_char(o.orderno)\n" + " ELSE\n" + " to_char(substr(o.orderno, 1, instr(o.orderno, '/') - 1))\n" + " END ordercode -- 销售凭证\n" + " ,CASE\n" + " WHEN o.orderid IS NULL\n" + " OR o.orderno LIKE 'HEGII%'\n" + " OR instr(o.orderno, '/') = 0 THEN\n" + " '0'\n" + " WHEN instr(o.orderno, '#') = 0 THEN\n" + " to_char(substr(o.orderno, instr(o.orderno, '/') + 1))\n" + " ELSE\n" + " to_char(substr(o.orderno\n" + " ,instr(o.orderno, '/') + 1\n" + " ,instr(o.orderno, '#') - instr(o.orderno, '/') - 1))\n" + " END orderitem -- 销售凭证项目\n" + " ,:LOGID\n" + " ,gdd.securitycode,'S'\n" + " FROM tp_pm_finishedproduct bar\n" + " INNER JOIN tp_pm_groutingdailydetail gdd\n" + " ON gdd.barcode = bar.barcode\n" + " INNER JOIN tp_mst_goods g\n" + " ON g.goodsid = gdd.goodsid\n" + " LEFT JOIN tp_pm_order o\n" + " ON o.orderid = bar.fhorderid\n" + " WHERE 1 = 1 " + fifter; //" WHERE :FHBatchNo = fhBatchNo"; oracleParameter = new OracleParameter[] { //new OracleParameter(":FHBatchNo",OracleDbType.Varchar2, fhBatchNo,ParameterDirection.Input), new OracleParameter(":yyyymmdd", yyyymmdd), new OracleParameter(":workcode", workcode), new OracleParameter(":LOGID", logid) }; r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); sqlString = "select bar.yyyymmdd\n" + " ,bar.workcode\n" + " ,bar.barcode\n" + " ,bar.outcode\n" + " ,bar.goodscode\n" + " ,bar.sapcode\n" + " ,bar.sapflbatchno\n" + " ,bar.sapfhundoflag\n" + " ,bar.ordercode\n" + " ,bar.orderitem\n" + " ,bar.securitycode\n" + //" from tsap_hegii_finishedproduct bar where ztype is null " + fifter + " from tsap_hegii_finishedproduct bar where LOGID=:LOGID " + " order by bar.sapflbatchno, bar.barcode"; oracleParameter = new OracleParameter[] { new OracleParameter(":LOGID", logid) }; DataTable fpData = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter); #region 注销 //// 单次传输最大条数 //int maxCount = 100000; //List sapParameterList = new List(); //if (fpData != null && fpData.Rows.Count > 0) //{ // int index = 0; // //Zppfm010 sapParameter = new Zppfm010(); // //sapParameter.Zsum = maxCount; // //sapParameter.TableIn = new Zspp110[sapParameter.Zsum]; // List tableInList = new List(); // foreach (DataRow item in fpData.Rows) // { // if (index >= maxCount) // { // Zppfm010 sapItem = new Zppfm010(); // sapItem.ZSUM = tableInList.Count; // sapItem.TABLE_IN = tableInList.ToArray(); // sapParameterList.Add(sapItem); // index = 0; // tableInList.Clear(); // } // ZSPP110 info110 = new ZSPP110(); // // 时间戳 // info110.ZSCNU = yyyymmdd; // // 工厂 // info110.WERKS = workcode; // // 生产条码 // info110.ZSCTM = item["barcode"].ToString(); // //生产防伪码 xuwei add 2021-12-09 // info110.SECURITYCODE = item["securitycode"].ToString(); // // 包装条码 // info110.ZBZTM = item["outcode"].ToString(); // // 产品编码 // info110.ZCPBM = item["goodscode"].ToString(); // // 物料编号 // info110.MATNR = item["sapcode"].ToString(); // // 包装整板标识 // info110.ZBZBS = item["sapflbatchno"].ToString(); // // 重新绑定标识 // info110.ZCXBD = item["sapfhundoflag"].ToString(); // // 销售凭证 // info110.KDAUF = item["ordercode"].ToString(); // // 销售凭证项目 // info110.KDPOS = item["orderitem"].ToString(); // info110.UZEIT = date.ToString("HH:mm:ss"); // info110.ZCODEN = ""; // info110.ZCODEYZM = ""; // //if (info110.WERKS == "5011" && info110.ZCPBM == "K047L") // //{ // // continue; // //} // tableInList.Add(info110); // index++; // } // Zppfm010 sapParameter010 = new Zppfm010(); // sapParameter010.ZSUM = tableInList.Count; // sapParameter010.TABLE_IN = tableInList.ToArray(); // sapParameterList.Add(sapParameter010); // index = 0; // tableInList.Clear(); //} //else //{ // Zppfm010 sapParameter010 = new Zppfm010(); // sapParameter010.ZSUM = 0; // sapParameter010.TABLE_IN = new ZSPP110[sapParameter010.ZSUM]; // sapParameterList.Add(sapParameter010); //} ////2022年9月23日13:06:25 添加时间限制,10月1号零点整不再传输原接口产量数据 //// 当前时间 //DateTime dateTimeNow = DateTime.Now; //DateTime setTime = new DateTime(2022, 10, 1, 0, 0, 0); //if (dateTimeNow < setTime) //{ // //foreach (Zppfm010 sapParameter010 in sapParameterList) // //{ // // //ZPPFM010Response result010 = SAPDataLogic.HGSAPDK_ZPPFM010(sapParameter010, yyyymmdd); // // //ZPPFM010Response result010 = SAPDataLogic.HGSAPDK_ZPPFM010_240(sapParameter010, yyyymmdd, sapName); // // ZPPFM010Response result010 = SAPDataLogic.HGSAPDK_ZPPFM010(sapParameter010, yyyymmdd, sapName); // // //sre.Message = result010.ZMSG; // // sre.Message = $"{result010.ZMSG}({sapParameter010.ZSUM})"; // // sre.Result = result010.ZTYPE; // // if (result010.TABLE_OUT != null && result010.TABLE_OUT.Length > 0) // // { // // sqlString = "update tsap_hegii_finishedproduct t set t.ZTime =sysdate, ZTYPE = nvl(:ZTYPE,'S'), ZMSG = :ZMSG where barcode=:barcode and sapflbatchno=:sapflbatchno and logid=:logid"; // // foreach (ZSPP110 item in result010.TABLE_OUT) // // { // // oracleParameter = new OracleParameter[] // // { // // new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item.ZTYPE, ParameterDirection.Input), // // new OracleParameter(":ZMSG",OracleDbType.Varchar2, item.ZMSG, ParameterDirection.Input), // // new OracleParameter(":barcode",OracleDbType.Varchar2, item.ZSCTM, ParameterDirection.Input), // // new OracleParameter(":sapflbatchno",OracleDbType.Varchar2, item.ZBZBS, ParameterDirection.Input), // // new OracleParameter(":logid", logid) // // }; // // r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); // // } // // } // // if (result010.ZTYPE != "S") // // { // // sre.Result = -2; // // sre.Message = "同步条码失败," + result010.ZMSG; // // return sre; // // } // //} //} #endregion #endregion #region 同步产量 //Zppfm008 sapParameter = new Zppfm008(); if (workData != null && workData.Rows.Count > 0) { //sapParameter.ZSUM = workData.Rows.Count; //sapParameter.TABLE_IN = new ZSPP100[sapParameter.ZSUM]; sqlString = "insert into TSAP_HEGII_WorkData\n" + " (YYYYMMDD\n" + " ,WorkCode\n" + " ,DataCode\n" + " ,GoodsCode\n" + " ,SAPCode\n" + " ,UserCode\n" + " ,OutputNum\n" + " ,RECOVERYNUM\n" + " ,ORDERCODE\n" + " ,ORDERITEM\n" + " ,testmouldflag\n" + " ,zscs\n" + " ,LogID,createtime)\n" + "values\n" + " ('" + yyyymmdd + "'\n" + " ,'" + workcode + "'\n" + " ,'60'\n" + " ,:GoodsCode\n" + " ,:SAPCode\n" + " ,:UserCode\n" + " ,:OutputNum\n" + " ,:RECOVERYNUM\n" + " ,:ORDERCODE\n" + " ,:ORDERITEM\n" + " ,:testmouldflag\n" + " ,:zscs\n" + " ," + logid + ",:createtime)"; //int index = 0; //DateTime now = DateTime.Now; foreach (DataRow item in workData.Rows) { //ZSPP100 info100 = new ZSPP100(); //// 工厂 //info100.WERKS = workcode; //// 型号 //info100.GROES = item["GoodsCode"].ToString(); //// 物料编号 //info100.MATNR = item["SAPCode"].ToString(); //// 生产工号 //info100.ZGHNU = item["UserCode"].ToString(); //// 数据节点 //info100.ZJDNU = "60"; //// 时间戳 //info100.ZSCNU = yyyymmdd; //// 销售凭证 //info100.VBELN = item["ORDERCODE"].ToString().Trim(); //// 销售凭证项目 //info100.POSNR = item["ORDERITEM"].ToString(); //// 产量 //info100.ZCLNG = item["OutputNum"].ToString(); //// 损坯 //info100.ZSPNG = "0"; //// 清除 //info100.ZQCNG = "0"; //// 回收 //info100.ZHSNG = item["RECOVERYNUM"].ToString(); //// 干补 //info100.ZGBNG = "0"; //// 注浆类型 G高压 L普通 M粘接高压(三车间) //info100.ZSCS = item["ZSCS"].ToString(); //info100.ZKSSJ = now.ToString("HHmmss"); //info100.ZJSRQ = Convert.ToDecimal(now.ToString("yyyyMMddHHmmss")); oracleParameter = new OracleParameter[] { new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item["GoodsCode"], ParameterDirection.Input), new OracleParameter(":SAPCode",OracleDbType.Varchar2, item["SAPCode"], ParameterDirection.Input), new OracleParameter(":UserCode",OracleDbType.Varchar2, item["UserCode"], ParameterDirection.Input), new OracleParameter(":OutputNum",OracleDbType.Varchar2, item["OutputNum"], ParameterDirection.Input), new OracleParameter(":RECOVERYNUM",OracleDbType.Varchar2, item["RECOVERYNUM"], ParameterDirection.Input), new OracleParameter(":ORDERCODE",OracleDbType.Varchar2, item["ORDERCODE"], ParameterDirection.Input), new OracleParameter(":ORDERITEM",OracleDbType.Varchar2, item["ORDERITEM"], ParameterDirection.Input), new OracleParameter(":testmouldflag",OracleDbType.Varchar2, item["TESTMOULDFLAG"], ParameterDirection.Input), new OracleParameter(":ZSCS",OracleDbType.Varchar2, item["ZSCS"], ParameterDirection.Input), new OracleParameter(":createtime",OracleDbType.Date, item["createtime"], ParameterDirection.Input), }; r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); //sapParameter.TABLE_IN[index++] = info100; } } //else //{ // sapParameter.ZSUM = 0; // sapParameter.TABLE_IN = new ZSPP100[sapParameter.ZSUM]; //} #endregion #region 注销 ////2022年9月23日13:06:25 添加时间限制,10月1号零点整不再传输原接口产量数据 //if (dateTimeNow < setTime) //{ // ////ZPPFM008Response result = SAPDataLogic.HGSAPDK_ZPPFM008(sapParameter, yyyymmdd, "60"); // //ZPPFM008Response result = SAPDataLogic.HGSAPDK_ZPPFM008(sapParameter, yyyymmdd, "60", sapName); // ////ZPPFM008Response result = SAPDataLogic.HGSAPDK_ZPPFM008_240(sapParameter, yyyymmdd, "60", sapName); // ////if (result.Ztype == "E") // ////{ // //// sqlString = "update tsap_hegii_datalog t set t.EndTime = sysdate, DataStuts = 'E', DataMSG = DataMSG||:msg where logid = :logid"; // //// oracleParameter = new OracleParameter[] // //// { // //// new OracleParameter(":msg",OracleDbType.Varchar2, result.Zmsg, ParameterDirection.Input), // //// new OracleParameter(":logid",OracleDbType.Int32, logid, ParameterDirection.Input), // //// }; // //// r = oracleConn.ExecuteNonQuery(sqlString, oracleParameter); // ////} // ////else // //if (result.TABLE_OUT != null && result.TABLE_OUT.Length > 0) // //{ // // sqlString = "update TSAP_HEGII_WorkData t set t.ZTime =sysdate, ZTYPE = :ZTYPE, ZMSG = :ZMSG where logid = " + logid + // // " \n and YYYYMMDD='" + yyyymmdd + "' and WorkCode='" + workcode + // // "' and DataCode='60' and GoodsCode=:GoodsCode and SAPCode=:SAPCode and UserCode=:UserCode \n" + // // "and OrderCode=:OrderCode and OrderItem=:OrderItem"; // // foreach (ZSPP100 item in result.TABLE_OUT) // // { // // string posnr = item.POSNR.TrimStart('0'); // // oracleParameter = new OracleParameter[] // // { // // new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item.ZTYPE, ParameterDirection.Input), // // new OracleParameter(":ZMSG",OracleDbType.Varchar2, item.ZMSG, ParameterDirection.Input), // // new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item.GROES, ParameterDirection.Input), // // new OracleParameter(":SAPCode",OracleDbType.Varchar2, item.MATNR, ParameterDirection.Input), // // new OracleParameter(":UserCode",OracleDbType.Varchar2, item.ZGHNU, ParameterDirection.Input), // // new OracleParameter(":OrderCode",OracleDbType.Varchar2, (string.IsNullOrEmpty(item.VBELN) ? " " : item.VBELN), ParameterDirection.Input), // // new OracleParameter(":OrderItem",OracleDbType.Varchar2, (string.IsNullOrEmpty(posnr) ? "0" : posnr), ParameterDirection.Input), // // }; // // r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); // // } // // //:msg||chr(13)||DataMSG // // result.ZMSG = $"{result.ZMSG}({sapParameter.ZSUM})"; // // sqlString = "update tsap_hegii_datalog t set t.EndTime = sysdate, DataStuts = :DataStuts, DataMSG =nvl2(:msg,:msg||' '||chr(13)||DataMSG,DataMSG) where logid = :logid"; // // oracleParameter = new OracleParameter[] // // { // // new OracleParameter(":DataStuts",OracleDbType.Varchar2, result.ZTYPE, ParameterDirection.Input), // // new OracleParameter(":msg",OracleDbType.Varchar2, result.ZMSG, ParameterDirection.Input), // // new OracleParameter(":logid",OracleDbType.Int32, logid, ParameterDirection.Input), // // }; // // r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); // //} // //if (result.ZTYPE != "S") // //{ // // sre.Result = -2; // // sre.Message = "同步产量失败," + result.ZMSG; // // return sre; // //} // //sqlString = // //"UPDATE tp_pm_groutingdailydetail bar\n" + // //" SET bar.issync = '1'\n" + // //" WHERE 1 = 1" + fifter; // //r = oracleTrConn.ExecuteNonQuery(sqlString); //} //else #endregion #region 调用新报工接口 workcode = "5000"; sqlString = @" SELECT TO_CHAR(SYSDATE, 'YYYYMMDD') AS YYYYMMDD, SYSDATE AS CREATETIME, TT.GOODSCODE GROES, TT.SAPCODE MATNR, TT.USERCODE ZGHNU, TT.ORDERCODE VBELN, TT.ORDERITEM POSNR, DECODE(TT.TESTMOULDFLAG, 0, 'C', 1, 'Y', '') ZSCMS, 'T' AS ZSCS, TO_CHAR(TT.OUTPUTNUM) AS ZCLNG, TO_CHAR(TT.RECOVERYNUM) AS ZHSNG, :WORKCODE WERKS, '60' ZJDNU, TO_CHAR(SYSDATE, 'YYYYMMDD') ZSCNU, TO_CHAR(SYSDATE, 'HH24MISS') ZKSSJ, TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') ZJSRQ, '0' ZSPNG, '0' ZQCNG, '0' ZGBNG, TO_CHAR(TT.WORKSHOP) ZSCCJ, '60' DATACODE, TT.CHARG FROM (SELECT T.GOODSCODE, T.SAPCODE, T.USERCODE, T.ORDERCODE, T.ORDERITEM, T.TESTMOULDFLAG, T.ZSCS, T.WORKSHOP, T.CHARG, SUM(DECODE(T.RECYCLINGFLAG, '1', 0, 1)) OUTPUTNUM, SUM(DECODE(T.RECYCLINGFLAG, '0', 0, 1)) RECOVERYNUM FROM (SELECT BAR.GOODSCODE, BAR.MATERIALCODE SAPCODE, GH.FHUSERCODE USERCODE, O.ORDERNO, BAR.RECYCLINGFLAG, BAR.TESTMOULDFLAG, DECODE(BAR.TESTMOULDFLAG ,'0' ,'' ,DECODE(G.GOODS_LINE_CODE, 'G', 'A', 'M', 'A', 'L', 'B', '')) AS ZSCS, CASE WHEN O.ORDERID IS NULL OR O.ORDERNO LIKE 'HEGII%' THEN ' ' WHEN INSTR(O.ORDERNO, '/') = 0 THEN TO_CHAR(O.ORDERNO) ELSE TO_CHAR(SUBSTR(O.ORDERNO, 1, INSTR(O.ORDERNO, '/') - 1)) END ORDERCODE -- 销售凭证 , CASE WHEN O.ORDERID IS NULL OR O.ORDERNO LIKE 'HEGII%' OR INSTR(O.ORDERNO, '/') = 0 THEN '0' WHEN INSTR(O.ORDERNO, '#') = 0 THEN TO_CHAR(SUBSTR(O.ORDERNO, INSTR(O.ORDERNO, '/') + 1)) ELSE TO_CHAR(SUBSTR(O.ORDERNO ,INSTR(O.ORDERNO, '/') + 1 ,INSTR(O.ORDERNO, '#') - INSTR(O.ORDERNO, '/') - 1)) END ORDERITEM, CASE WHEN (INSTR(BAR.GROUTINGLINECODE, 'A') = 1 OR INSTR(BAR.GROUTINGLINECODE, 'D') = 1) AND INSTR(GT.GOODSTYPECODE, '001002') = 1 THEN 1 WHEN (INSTR(BAR.GROUTINGLINECODE, 'B') = 1 OR INSTR(BAR.GROUTINGLINECODE, 'D') = 1) AND INSTR(GT.GOODSTYPECODE, '001001') = 1 THEN 2 WHEN INSTR(BAR.GROUTINGLINECODE, 'C') = 1 THEN 3 ELSE 9 END AS WORKSHOP, TO_CHAR(GH.FHTIME, 'yyyymm') AS CHARG FROM TP_PM_GROUTINGDAILYDETAIL BAR INNER JOIN TP_PM_FINISHEDPRODUCT GH ON BAR.GROUTINGDAILYDETAILID = GH.GROUTINGDAILYDETAILID INNER JOIN TP_MST_GOODS G ON G.GOODSID = BAR.GOODSID INNER JOIN TP_MST_GOODSTYPE GT ON GT.GOODSTYPEID = G.GOODSTYPEID LEFT JOIN TP_PM_ORDER O ON O.ORDERID = GH.FHORDERID WHERE 1 = 1 " + fifter + @") T GROUP BY T.GOODSCODE, T.SAPCODE, T.USERCODE, T.ORDERCODE, T.ORDERITEM, T.TESTMOULDFLAG, T.ZSCS, T.WORKSHOP, T.CHARG) TT WHERE TT.OUTPUTNUM <> 0 OR TT.RECOVERYNUM <> 0 ORDER BY TT.GOODSCODE, TT.SAPCODE, TT.USERCODE, TT.ORDERCODE, TT.ORDERITEM, TT.ZSCS, TT.WORKSHOP, TT.CHARG "; oracleParameter = new OracleParameter[] { new OracleParameter(":WORKCODE", workcode) }; DataTable workData5000 = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter); //string logid_bg = oracleTrConn.GetSqlResultToStr("select SEQ_TSAP_DATALOG_BG.Nextval from dual"); sqlString = "insert into TSAP_HEGII_DATALOG_BG\n" + " (LogID\n" + " ,LogType\n" + " ,BeginTime\n" + " ,YYYYMMDD\n" + " ,WorkCode\n" + " ,DataCode\n" + " ,DataStuts\n" + " ,DataMSG\n" + " ,DATALOGID\n" + " ,EXECUTEDATEBEGIN\n" + " ,EXECUTEDATEEND,SAPGUID)\n" + "values\n" + " (:LogID\n" + " ,'2'\n" + " ,sysdate\n" + " ,:YYYYMMDD\n" + " ,'5000'\n" + " ,'60'\n" + " ,'F'\n" + " ,:DataMSG\n" + " ,:LogID\n" + " ,sysdate\n" + " ,sysdate,sys_guid())"; oracleParameter = new OracleParameter[] { new OracleParameter(":LogID",OracleDbType.Int32, logid_bg, ParameterDirection.Input), new OracleParameter(":YYYYMMDD",OracleDbType.Varchar2, yyyymmdd, ParameterDirection.Input), new OracleParameter(":DataMSG",OracleDbType.Varchar2, "", ParameterDirection.Input), }; r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); //DateTime now = DateTime.Now; sqlString = "insert into TSAP_HEGII_WORKDATA_BG\n" + " (YYYYMMDD\n" + " ,WorkCode\n" + " ,DataCode\n" + " ,GoodsCode\n" + " ,SAPCode\n" + " ,UserCode\n" + " ,WORKSHOP\n" + " ,OutputNum\n" + " ,RECOVERYNUM\n" + " ,ORDERCODE\n" + " ,ORDERITEM\n" + " ,testmouldflag\n" + " ,zscs\n" + " ,LogID,createtime,workdataid,charg)\n" + "values\n" + " ('" + yyyymmdd + "'\n" + " ,'5000'\n" + " ,'60'\n" + " ,:GoodsCode\n" + " ,:SAPCode\n" + " ,:UserCode\n" + " ,:ZSCCJ\n" + " ,:OutputNum\n" + " ,:RECOVERYNUM\n" + " ,:ORDERCODE\n" + " ,:ORDERITEM\n" + " ,:testmouldflag\n" + " ,:zscs\n" + " ," + logid_bg + ",:createtime,:workdataid,:charg)"; foreach (DataRow item in workData5000.Rows) { string workdataid = oracleTrConn.GetSqlResultToStr("select SEQ_HEGII_WORKDATA_BG.Nextval from dual"); oracleParameter = new OracleParameter[] { new OracleParameter(":GoodsCode", item["GROES"].ToString()), new OracleParameter(":SAPCode", item["MATNR"].ToString()), new OracleParameter(":UserCode", item["ZGHNU"].ToString()), new OracleParameter(":ZSCCJ", item["ZSCCJ"].ToString()), new OracleParameter(":OutputNum", item["ZCLNG"].ToString()), new OracleParameter(":RECOVERYNUM", item["ZHSNG"].ToString()), new OracleParameter(":ORDERCODE", item["VBELN"].ToString()), new OracleParameter(":ORDERITEM", item["POSNR"].ToString()), new OracleParameter(":testmouldflag", item["ZSCMS"].ToString()), new OracleParameter(":zscs", item["ZSCS"].ToString()), new OracleParameter(":createtime", OracleDbType.Date,item["createtime"], ParameterDirection.Input), new OracleParameter(":workdataid", workdataid), new OracleParameter(":charg", item["CHARG"].ToString()), }; r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); } sqlString = "SELECT TO_CHAR(wd.yyyymmdd) yyyymmdd\n" + " ,TO_CHAR(5000) WERKS\n" + " ,TO_CHAR(wd.goodscode) GROES\n" + " ,TO_CHAR(wd.sapcode) MATNR\n" + " ,TO_CHAR(wd.usercode) ZGHNU\n" + " ,TO_CHAR(wd.datacode) ZJDNU\n" + " ,to_char(sysdate, 'YYYYMMDD' ) ZSCNU\n" + " ,to_char(sysdate, 'HH24MISS' ) ZKSSJ\n" + " ,to_char(sysdate, 'YYYYMMDDHH24MISS' ) ZJSRQ\n" + " ,TO_CHAR(wd.ordercode) VBELN\n" + " ,TO_CHAR(wd.orderitem) POSNR\n" + " ,TO_CHAR(wd.outputnum) ZCLNG\n" + " ,TO_CHAR(wd.scrapnum) ZSPNG\n" + " ,TO_CHAR(wd.cleanupnum) ZQCNG\n" + " ,TO_CHAR(wd.recoverynum) ZHSNG\n" + " ,TO_CHAR(wd.repairnum) ZGBNG\n" + " ,TO_CHAR(wd.testmouldflag) ZSCMS\n" + " -- ,TO_CHAR(wd.zscs) zscs\n" + " ,'T' AS zscs\n" + " ,TO_CHAR(wd.WORKSHOP) ZSCCJ\n" + " ,WD.CHARG\n" + " ,TO_CHAR(60) datacode\n" + " ,'5000' || LPAD(DL.LOGID, 10,'0') AS ZID\n" + " FROM tsap_hegii_workdata_bg wd\n" + " INNER JOIN TSAP_HEGII_DATALOG_BG DL\n" + " ON wd.LOGID = DL.LOGID \n" + " WHERE wd.logid = :logid"; OracleParameter[] par = null; par = new OracleParameter[] { new OracleParameter(":logid", OracleDbType.Int32, logid_bg, ParameterDirection.Input), }; DataTable dtt = oracleTrConn.GetSqlResultToDt(sqlString, par); int num = dtt.Rows.Count; //string sq = "select SAP_INI_BG from TP_SYS_SAPCONFIG"; //string SAP_ING_NEW = oracleTrConn.GetSqlResultToStr(sq); //if (SAP_ING_NEW == "1") //if (true) //{ // 调用SAP接口 string postString = "{\"ZSUM\":" + num.ToString() + ",\"TABLE_IN\":{\"item\":" + JsonHelper.ToJson(ModelConvertHelper.ConvertToModel(dtt)) + "}}"; INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII); string url030 = ini.ReadIniData("SAP_NEW_INFO", "Url030"); //string url030 = "http://hgs4podev.hegii.com:50200/RESTAdapter/DKMES/ZPPFM030"; // 调外公司接口如何不背锅第一要义: // 1、post的时候,一定要加上try catch。出现错误一定要把是哪个公司哪个接口的错误信息,简单明了的显示给客户。千万不要就弹个系统异常,请联系管理员。 // 2、post前后,一定要把传入传出的json存到log里,日后扯皮时一定有用。 string result = string.Empty; try { result = SAPDataLogic.PostData(url030, postString, "POST"); } catch (Exception ex) { sre.Result = -2; sre.Message = "sap030接口同步失败," + ex.Message; return sre; } if (JObject.Parse(result)["TABLE_OUT"] != null && JObject.Parse(result)["TABLE_OUT"].ToString().Length > 0) { sqlString = "update TSAP_HEGII_WorkData_bg t set t.ZTime =sysdate, ZTYPE = :ZTYPE, ZMSG = :ZMSG where logid = " + logid_bg + " \n and YYYYMMDD='" + yyyymmdd + "' and WorkCode='" + workcode + "' and DataCode='60' and GoodsCode=:GoodsCode and SAPCode=:SAPCode and UserCode=:UserCode \n" + "and OrderCode=:OrderCode and OrderItem=:OrderItem"; Dictionary obj = JsonConvert.DeserializeObject>(result); object TABLE_OUT; obj.TryGetValue("TABLE_OUT", out TABLE_OUT); obj = JsonConvert.DeserializeObject>(TABLE_OUT + ""); object item1; obj.TryGetValue("item", out item1); JArray arr = JArray.FromObject(item1); foreach (JObject item60 in arr) { string posnr = item60["POSNR"].ToString().TrimStart('0'); oracleParameter = new OracleParameter[] { new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item60["ZTYPE"].ToString(), ParameterDirection.Input), new OracleParameter(":ZMSG",OracleDbType.Varchar2, item60["ZMSG"].ToString(), ParameterDirection.Input), new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item60["GROES"].ToString(), ParameterDirection.Input), new OracleParameter(":SAPCode",OracleDbType.Varchar2, item60["MATNR"].ToString(), ParameterDirection.Input), new OracleParameter(":UserCode",OracleDbType.Varchar2, item60["ZGHNU"].ToString(), ParameterDirection.Input), new OracleParameter(":OrderCode",OracleDbType.Varchar2, (string.IsNullOrEmpty(item60["VBELN"].ToString()) ? " " : item60["VBELN"].ToString()), ParameterDirection.Input), new OracleParameter(":Orderitem",OracleDbType.Varchar2, ((string.IsNullOrEmpty(posnr)) ? "0" : posnr), ParameterDirection.Input), }; r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); } //:msg||chr(13)||DataMSG JObject.Parse(result)["ZMSG"] = $"{JObject.Parse(result)["ZMSG"]}(" + num + ")"; sqlString = "update tsap_hegii_datalog_bg t set t.EndTime = sysdate, DataStuts = :DataStuts, DataMSG =nvl2(:msg,:msg||' '||chr(13)||DataMSG,DataMSG) where logid = :logid"; oracleParameter = new OracleParameter[] { new OracleParameter(":DataStuts",OracleDbType.Varchar2, JObject.Parse(result)["ZTYPE"].ToString(), ParameterDirection.Input), new OracleParameter(":msg",OracleDbType.Varchar2, JObject.Parse(result)["ZMSG"].ToString(), ParameterDirection.Input), new OracleParameter(":logid",OracleDbType.Int32, logid_bg, ParameterDirection.Input), }; r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); } if (JObject.Parse(result)["ZTYPE"].ToString() != "S") { sre.Result = -2; sre.Message = "同步产量失败," + JObject.Parse(result)["ZMSG"].ToString(); return sre; } //sqlString = //"UPDATE tp_pm_groutingdailydetail bar\n" + //" SET bar.issync = '1'\n" + //" WHERE 1 = 1" + fifter; //r = oracleTrConn.ExecuteNonQuery(sqlString); //} #endregion sqlString = "update TSAP_HEGII_WorkData t set t.ZTime =sysdate, ZTYPE = 'S' where logid = " + logid + " \n and YYYYMMDD='" + yyyymmdd + "' and WorkCode='" + workcode + "' and DataCode='60' and GoodsCode=:GoodsCode and SAPCode=:SAPCode \n" + "and OrderCode=:OrderCode and OrderItem=:OrderItem"; foreach (DataRow row in fpData.Rows) { string posnr = (row["ORDERITEM"] + "").TrimStart('0'); oracleParameter = new OracleParameter[] { new OracleParameter(":GoodsCode",OracleDbType.Varchar2, row["GoodsCode"], ParameterDirection.Input), new OracleParameter(":SAPCode",OracleDbType.Varchar2, row["SAPCode"], ParameterDirection.Input), //new OracleParameter(":UserCode",OracleDbType.Varchar2, row["UserCode"], ParameterDirection.Input), new OracleParameter(":OrderCode",OracleDbType.Varchar2, (string.IsNullOrEmpty(row["OrderCode"] + "") ? " " :row["OrderCode"]), ParameterDirection.Input), new OracleParameter(":OrderItem",OracleDbType.Varchar2, (string.IsNullOrEmpty(posnr) ? "0" : posnr), ParameterDirection.Input), }; r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); } #endregion #region 同步WMS系统 if (fpData.Rows.Count > 0) { DateTime now = DateTime.Now; string message = WMSDataLogic.PushWMS(fpData, now); // 同步日志 sqlString = @" INSERT INTO TP_WMS_LOG (LOGTYPE, SPS, SKU, SERIALNO, ADDDAY, ADDTIME, CODEI, UDF1, UDF2, LPN, RETURNDESC, ACCOUNTID, CREATETIME, UPDATETIME, CREATEUSERID, UPDATEUSERID) VALUES (:LOGTYPE, :SPS, :SKU, :SERIALNO, :ADDDAY, :ADDTIME, :CODEI, :UDF1, :UDF2, :LPN, :RETURNDESC, :ACCOUNTID, :CREATETIME, :CREATETIME, :USERID, :USERID) "; string orderitem; foreach (DataRow row in fpData.Rows) { orderitem = row["orderitem"] + ""; if (string.IsNullOrEmpty(orderitem) || "0".Equals(orderitem)) { orderitem = "000000"; } oracleParameter = new OracleParameter[] { new OracleParameter(":LOGTYPE",OracleDbType.Int32, 1, ParameterDirection.Input), new OracleParameter(":SPS",OracleDbType.Varchar2, "5020", ParameterDirection.Input), new OracleParameter(":SKU",OracleDbType.Varchar2, row["sapcode"], ParameterDirection.Input), new OracleParameter(":SERIALNO",OracleDbType.Varchar2, row["outcode"], ParameterDirection.Input), new OracleParameter(":ADDDAY",OracleDbType.Varchar2, now.ToString("yyyyMMdd"), ParameterDirection.Input), new OracleParameter(":ADDTIME",OracleDbType.Varchar2, now.ToString("HHmmss"), ParameterDirection.Input), new OracleParameter(":CODEI",OracleDbType.Varchar2, row["barcode"], ParameterDirection.Input), new OracleParameter(":UDF1",OracleDbType.Varchar2, row["ordercode"], ParameterDirection.Input), new OracleParameter(":UDF2",OracleDbType.Varchar2, orderitem, ParameterDirection.Input), new OracleParameter(":LPN",OracleDbType.Varchar2, row["sapflbatchno"], ParameterDirection.Input), new OracleParameter(":RETURNDESC",OracleDbType.Varchar2, message, ParameterDirection.Input), new OracleParameter(":ACCOUNTID",OracleDbType.Varchar2, sUserInfo.AccountID, ParameterDirection.Input), new OracleParameter(":CREATETIME",OracleDbType.Date, now, ParameterDirection.Input), new OracleParameter(":USERID",OracleDbType.Varchar2, sUserInfo.UserID, ParameterDirection.Input), }; r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); } sqlString = "UPDATE tp_pm_groutingdailydetail bar\n" + " SET bar.issync = '1'\n" + " WHERE 1 = 1" + fifter; r = oracleTrConn.ExecuteNonQuery(sqlString); } #endregion #region 释放包材库库存 sqlString = "SELECT 1\n" + " FROM tp_pm_groutingdailydetail bar\n" + " WHERE bar.packingby3 = '1' " + fifter; isExists = oracleTrConn.GetSqlResultToObj(sqlString); if (isExists != null) { //INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII); string packingURL = ini.ReadIniData("SAP_HEGII", "PackingURL"); foreach (DataRow row in workData.Rows) { string url = packingURL + row["sapcode"] + "&num=" + row["outputnum"]; WebRequest req = WebRequest.Create(url); req.Method = "GET"; Stream stream = req.GetResponse().GetResponseStream(); StreamReader reader = new StreamReader(stream); JObject json = JObject.Parse(reader.ReadToEnd()); // 包材库失败暂时不处理 TODO if (json["success"].ToString() == "false") { //sre.Result = -2; //sre.Message = json["message"].ToString(); //return sre; } } } #endregion sre.Result = 1; oracleTrConn.Commit(); oracleTrConn.Disconnect(); return sre; } catch (Exception ex) { if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Rollback(); oracleTrConn.Disconnect(); } throw ex; } finally { if (oracleTrConn.ConnState == ConnectionState.Open) { oracleTrConn.Disconnect(); } } } /// /// 撤销整板交接 /// /// /// /// /// public static ServiceResultEntity BackFinishedHandover(DataTable dtData, SUserInfo sUserInfo) { ServiceResultEntity sre = new ServiceResultEntity(); if (dtData == null || dtData.Rows.Count == 0) { sre.Result = -2; sre.Message = "条码信息不能为空"; return sre; } string logid_bg = "0"; OracleParameter[] Paras = null; // 条码串 string fifter = " AND (bar.barcode = '"; foreach (DataRow row in dtData.Rows) { fifter += row["barcode"] + "' OR bar.barcode = '"; } fifter = fifter.Substring(0, fifter.Length - 18) + ")"; IDBTransaction oracleTrConn2 = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { #region 相关校验 string sql = ""; // 本批交接的批次号 for (int i = 0; i < dtData.Rows.Count; i++) { // 1.判断产品是否在产成品表中 sql = @"select FHUserID, FHUserCode, GoodsID, GoodsCode, GoodsName from TP_PM_FinishedProduct where BarCode=:BarCode"; Paras = new OracleParameter[] { new OracleParameter(":BarCode",OracleDbType.NVarchar2,dtData.Rows[i]["barcode"],ParameterDirection.Input), }; DataSet dsResult = oracleTrConn2.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)) { sre.Result = -1; //未交接,不能撤销 sre.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】未交接,不能进行该操作"; return sre; } #endregion } else { sre.Result = -2; //不能产成品,不能撤销 sql = "select GoodsCode from TP_PM_GroutingDailyDetail where BarCode=:BarCode"; dsResult = oracleTrConn2.GetSqlResultToDs(sql, Paras); if (dsResult != null && dsResult.Tables[0].Rows.Count > 0) { sre.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】不是产成品,不能进行该操作"; } else { sre.Message = "此条码【" + dtData.Rows[i]["barcode"] + "】无效,不能进行该操作"; } return sre; } } #endregion sql = @" SELECT DISTINCT BGLOGIDCX FROM TP_PM_FINISHEDPRODUCT BAR WHERE 1 = 1 " + fifter; string currentBGlogid = oracleTrConn2.GetSqlResultToStr(sql); if (string.IsNullOrEmpty(currentBGlogid)) { logid_bg = oracleTrConn2.GetSqlResultToStr("select SEQ_TSAP_DATALOG_BG.Nextval from dual"); sql = @" UPDATE TP_PM_FINISHEDPRODUCT BAR SET BAR.BGLOGID = NULL ,BAR.BGLOGIDCX = " + logid_bg + @" WHERE 1 = 1 " + fifter; int r2 = oracleTrConn2.ExecuteNonQuery(sql); } else { logid_bg = currentBGlogid; } oracleTrConn2.Commit(); oracleTrConn2.Disconnect(); } catch (Exception ex) { throw ex; } IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { string sql = string.Empty; oracleTrConn.Connect(); #region 相关校验 // 本批交接的批次号 for (int i = 0; i < dtData.Rows.Count; i++) { // 1.判断产品是否在产成品表中 sql = @"select FHUserID, FHUserCode, GoodsID, GoodsCode, GoodsName from TP_PM_FinishedProduct where BarCode=:BarCode"; Paras = new OracleParameter[] { new OracleParameter(":BarCode",OracleDbType.NVarchar2,dtData.Rows[i]["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)) { sre.Result = -1; //未交接,不能撤销 sre.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】未交接,不能进行该操作"; return sre; } #endregion } else { sre.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) { sre.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】不是产成品,不能进行该操作"; } else { sre.Message = "此条码【" + dtData.Rows[i]["barcode"] + "】无效,不能进行该操作"; } return sre; } } #endregion #region 同步SAP #region 取相关数据 object isExists; string sqlString = string.Empty; OracleParameter[] oracleParameter = null; int r = 0; //// 条码串 //string fifter = " AND (bar.barcode = '"; //foreach (DataRow row in dtData.Rows) //{ // fifter += row["barcode"] + "' OR bar.barcode = '"; //} //fifter = fifter.Substring(0, fifter.Length - 18) + ")"; //sqlString = "SELECT 1\n" + //" FROM tp_pm_groutingdailydetail bar\n" + //" WHERE bar.issync IS NULL" + fifter; //object isExists = oracleTrConn.GetSqlResultToObj(sqlString, oracleParameter); //if (isExists != null) //{ // sre.Result = -2; // sre.Message = "当前产品已经撤销,不能重复同步。"; // return sre; //} DateTime date = DateTime.Now; string yyyymmdd = date.ToString("yyyyMMdd"); sqlString = "select workcode from tp_mst_account where rownum = 1"; string workcode = oracleTrConn.GetSqlResultToStr(sqlString); //DateTime datebegin = date.Date; //DateTime dateend = date.Date.AddDays(1); //sqlString = //"SELECT :yyyymmdd AS yyyymmdd\n" + //" ,SYSDATE AS createtime\n" + //" ,tt.goodscode\n" + //" ,tt.sapcode\n" + //" ,tt.usercode\n" + //" ,tt.ordercode\n" + //" ,tt.orderitem\n" + //" ,tt.zscs\n" + //" ,to_char(tt.outputnum) AS outputnum\n" + //" ,to_char(tt.recoverynum) AS recoverynum\n" + //" FROM (SELECT t.goodscode\n" + //" ,t.sapcode\n" + //" ,t.usercode\n" + //" ,t.ordercode\n" + //" ,t.orderitem\n" + //" ,t.zscs\n" + //" ,0 - SUM(decode(t.recyclingflag, '1', 0, decode(t.datatype, 51, 1, -1))) outputnum\n" + //" ,0 - SUM(decode(t.recyclingflag, '0', 0, decode(t.datatype, 51, 1, -1))) recoverynum\n" + //" FROM (SELECT gh.goodscode\n" + //" ,gh.sapcode\n" + //" ,u.usercode\n" + //" ,o.orderno\n" + //" ,bar.recyclingflag\n" + //" ,gh.datatype\n" + //" ,'' zscs\n" + ////" ,g.goods_line_code zscs\n" + //" ,CASE\n" + //" WHEN o.orderid IS NULL\n" + //" OR o.orderno LIKE 'HEGII%' THEN\n" + //" ' '\n" + //" WHEN instr(o.orderno, '/') = 0 THEN\n" + //" to_char(o.orderno)\n" + //" ELSE\n" + //" to_char(substr(o.orderno, 1, instr(o.orderno, '/') - 1))\n" + //" END ordercode -- 销售凭证\n" + //" ,CASE\n" + //" WHEN o.orderid IS NULL\n" + //" OR o.orderno LIKE 'HEGII%'\n" + //" OR instr(o.orderno, '/') = 0 THEN\n" + //" '0'\n" + //" WHEN instr(o.orderno, '#') = 0 THEN\n" + //" to_char(substr(o.orderno, instr(o.orderno, '/') + 1))\n" + //" ELSE\n" + //" to_char(substr(o.orderno\n" + //" ,instr(o.orderno, '/') + 1\n" + //" ,instr(o.orderno, '#') - instr(o.orderno, '/') - 1))\n" + //" END orderitem -- 销售凭证项目\n" + //" FROM (SELECT gch.goodscode\n" + //" ,gch.sapcode\n" + //" ,decode(gch.datatype, 53, 51, gch.datatype) datatype\n" + //" ,gch.userid\n" + //" ,gch.groutingdailydetailid\n" + //" ,gch.otherid\n" + //" FROM tp_pm_goodschangehistory gch\n" + //" WHERE gch.datatype IN (51, 52, 53)\n" + //" UNION ALL\n" + //" SELECT gch.goodscode\n" + //" ,gch.sapcode\n" + //" ,52 datatype\n" + //" ,gch.userid\n" + //" ,gch.groutingdailydetailid\n" + //" ,gch.goodsidafter\n" + //" FROM tp_pm_goodschangehistory gch\n" + //" WHERE gch.datatype = 53) gh\n" + //" INNER JOIN tp_mst_user u\n" + //" ON u.userid = gh.userid\n" + //" INNER JOIN tp_pm_groutingdailydetail bar\n" + //" ON bar.groutingdailydetailid = gh.groutingdailydetailid\n" + fifter + //" INNER JOIN tp_mst_goods g\n" + //" ON g.goodsid = bar.goodsid\n" + //" LEFT JOIN tp_pm_order o\n" + //" ON o.orderid = gh.otherid) t\n" + //" GROUP BY t.goodscode\n" + //" ,t.sapcode\n" + //" ,t.usercode\n" + //" ,t.ordercode\n" + //" ,t.orderitem,t.zscs) tt\n" + //" WHERE tt.outputnum <> 0\n" + //" OR tt.recoverynum <> 0\n" + //" ORDER BY tt.goodscode\n" + //" ,tt.sapcode\n" + //" ,tt.usercode\n" + //" ,tt.ordercode\n" + //" ,tt.orderitem,tt.zscs"; sqlString = "SELECT :yyyymmdd AS yyyymmdd\n" + " ,SYSDATE AS createtime\n" + " ,tt.goodscode\n" + " ,tt.sapcode\n" + " ,tt.usercode\n" + " ,tt.ordercode\n" + " ,tt.orderitem\n" + " ,tt.testmouldflag\n" + " ,tt.zscs\n" + " ,to_char(tt.outputnum) AS outputnum\n" + " ,to_char(tt.recoverynum) AS recoverynum\n" + " FROM (SELECT t.goodscode\n" + " ,t.sapcode\n" + " ,t.usercode\n" + " ,t.ordercode\n" + " ,t.orderitem\n" + " ,t.testmouldflag\n" + " ,t.zscs\n" + //" ,0-SUM(decode(t.recyclingflag, '1', 0, decode(t.datatype, 51, 1, -1))) outputnum\n" + //" ,0-SUM(decode(t.recyclingflag, '0', 0, decode(t.datatype, 51, 1, -1))) recoverynum\n" + " ,0-SUM(decode(t.recyclingflag, '1', 0, 1)) outputnum\n" + " ,0-SUM(decode(t.recyclingflag, '0', 0, 1)) recoverynum\n" + " FROM (SELECT bar.goodscode\n" + //" ,gh.sapcode\n" + //" ,u.usercode\n" + " ,bar.materialcode sapcode\n" + " ,gh.fhusercode usercode\n" + " ,o.orderno\n" + " ,bar.recyclingflag\n" + //" ,gh.datatype\n" + //" ,'' zscs\n" + //" ,case when g.goods_line_type = 1 or gl.highpressureflag = '1' then 'G' else 'L' end zscs\n" + " ,bar.testmouldflag" + " ,decode(bar.testmouldflag,'0', '', decode(g.goods_line_code,'G','A','M','A','L','B','')) as zscs\n" + " ,CASE\n" + " WHEN o.orderid IS NULL\n" + " OR o.orderno LIKE 'HEGII%' THEN\n" + " ' '\n" + " WHEN instr(o.orderno, '/') = 0 THEN\n" + " to_char(o.orderno)\n" + " ELSE\n" + " to_char(substr(o.orderno, 1, instr(o.orderno, '/') - 1))\n" + " END ordercode -- 销售凭证\n" + " ,CASE\n" + " WHEN o.orderid IS NULL\n" + " OR o.orderno LIKE 'HEGII%'\n" + " OR instr(o.orderno, '/') = 0 THEN\n" + " '0'\n" + " WHEN instr(o.orderno, '#') = 0 THEN\n" + " to_char(substr(o.orderno, instr(o.orderno, '/') + 1))\n" + " ELSE\n" + " to_char(substr(o.orderno\n" + " ,instr(o.orderno, '/') + 1\n" + " ,instr(o.orderno, '#') - instr(o.orderno, '/') - 1))\n" + " END orderitem -- 销售凭证项目\n" + " FROM tp_pm_groutingdailydetail bar\n" + //" INNER JOIN tp_mst_user u\n" + //" ON u.userid = gh.userid\n" + " INNER JOIN tp_pm_finishedproduct gh\n" + " ON bar.groutingdailydetailid = gh.groutingdailydetailid\n" + //" AND bar.barcode IN (" + fifter + ")\n" + //" INNER JOIN tp_pc_groutingline gl\n" + //" ON gl.groutinglineid = bar.groutinglineid\n" + " INNER JOIN tp_mst_goods g\n" + " ON g.goodsid = bar.goodsid\n" + " LEFT JOIN tp_pm_order o\n" + " ON o.orderid = gh.fhorderid where 1=1 " + fifter + ") t\n" + " GROUP BY t.goodscode\n" + " ,t.sapcode\n" + " ,t.usercode\n" + " ,t.ordercode\n" + " ,t.orderitem,t.testmouldflag,t.zscs) tt\n" + " WHERE tt.outputnum <> 0\n" + " OR tt.recoverynum <> 0\n" + " ORDER BY tt.goodscode\n" + " ,tt.sapcode\n" + " ,tt.usercode\n" + " ,tt.ordercode\n" + " ,tt.orderitem,tt.zscs"; oracleParameter = new OracleParameter[] { new OracleParameter(":yyyymmdd", yyyymmdd) }; DataTable workData = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter); string logid = oracleTrConn.GetSqlResultToStr("select SEQ_SAP_HEGII_DataLog_ID.Nextval from dual"); //string msg = "撤销同步,data:" + datebegin.ToString("yyyyMMdd-HHmm") + "~" + // dateend.ToString("yyyyMMdd-HHmm"); string msg = $"整板撤销[{logid}]:" + dtData.Rows[0]["barcode"]; sqlString = "insert into tsap_hegii_datalog\n" + " (LogID\n" + " ,LogType\n" + " ,BeginTime\n" + " ,YYYYMMDD\n" + " ,WorkCode\n" + " ,DataCode\n" + " ,DataStuts\n" + " ,DataMSG\n" + " ,CreateUserID\n" + " ,DataLogID)\n" + "values\n" + " (:LogID\n" + " ,'2'\n" + " ,sysdate\n" + " ,:YYYYMMDD\n" + " ,:WorkCode\n" + " ,'60'\n" + " ,'S'\n" + " ,:DataMSG\n" + " ,:CreateUserID\n" + " ,:LogID)"; oracleParameter = new OracleParameter[] { new OracleParameter(":LogID",OracleDbType.Int32, logid, ParameterDirection.Input), new OracleParameter(":CreateUserID",OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input), new OracleParameter(":YYYYMMDD",OracleDbType.Varchar2, yyyymmdd, ParameterDirection.Input), new OracleParameter(":WorkCode",OracleDbType.Varchar2, workcode, ParameterDirection.Input), new OracleParameter(":DataMSG",OracleDbType.Varchar2, msg, ParameterDirection.Input), }; r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); #endregion #region 同步条码明细(注销) sqlString = "select bar.yyyymmdd\n" + " ,bar.workcode\n" + " ,bar.barcode\n" + " ,bar.outcode\n" + " ,bar.goodscode\n" + " ,bar.sapcode\n" + " ,bar.sapflbatchno\n" + " ,bar.sapfhundoflag\n" + " ,bar.ordercode\n" + " ,bar.orderitem\n" + // 保留条码同步履历 2020-10-14 by chenxy ztype = 'S' //" from tsap_hegii_finishedproduct bar where 1 = 1" + fifter + " from tsap_hegii_finishedproduct bar where ztype = 'S' " + fifter + " order by bar.sapflbatchno, bar.barcode"; DataTable fpData = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter); #region 注销 //// 单次传输最大条数 //int maxCount = 100000; //List sapParameterList = new List(); //if (fpData != null && fpData.Rows.Count > 0) //{ // int index = 0; // //Zppfm010 sapParameter = new Zppfm010(); // //sapParameter.Zsum = maxCount; // //sapParameter.TableIn = new Zspp110[sapParameter.Zsum]; // List tableInList = new List(); // foreach (DataRow item in fpData.Rows) // { // if (index >= maxCount) // { // Zppfm010 sapItem = new Zppfm010(); // sapItem.ZSUM = tableInList.Count; // sapItem.TABLE_IN = tableInList.ToArray(); // sapParameterList.Add(sapItem); // index = 0; // tableInList.Clear(); // } // ZSPP110 info110 = new ZSPP110(); // // 时间戳 // info110.ZSCNU = yyyymmdd; // // 工厂 // info110.WERKS = workcode; // // 生产条码 // info110.ZSCTM = item["barcode"].ToString(); // // 包装条码 // info110.ZBZTM = item["outcode"].ToString(); // // 产品编码 // info110.ZCPBM = item["goodscode"].ToString(); // // 物料编号 // info110.MATNR = item["sapcode"].ToString(); // // 包装整板标识 // info110.ZBZBS = item["sapflbatchno"].ToString(); // // 重新绑定标识 // info110.ZCXBD = "X"; // // 销售凭证 // info110.KDAUF = item["ordercode"].ToString(); // // 销售凭证项目 // info110.KDPOS = item["orderitem"].ToString(); // info110.UZEIT = date.ToString("HH:mm:ss"); // info110.ZCODEN = ""; // info110.ZCODEYZM = ""; // //if (info110.WERKS == "5011" && info110.ZCPBM == "K047L") // //{ // // continue; // //} // tableInList.Add(info110); // index++; // } // Zppfm010 sapParameter010 = new Zppfm010(); // sapParameter010.ZSUM = tableInList.Count; // sapParameter010.TABLE_IN = tableInList.ToArray(); // sapParameterList.Add(sapParameter010); // index = 0; // tableInList.Clear(); //} //else //{ // Zppfm010 sapParameter010 = new Zppfm010(); // sapParameter010.ZSUM = 0; // sapParameter010.TABLE_IN = new ZSPP110[sapParameter010.ZSUM]; // sapParameterList.Add(sapParameter010); //} ////2022年9月23日13:06:25 添加时间限制,10月1号零点整不再传输原接口产量数据 //// 当前时间 //DateTime dateTimeNow = DateTime.Now; //DateTime setTime = new DateTime(2022, 10, 1, 0, 0, 0); //if (dateTimeNow < setTime) //{ // //foreach (Zppfm010 sapParameter010 in sapParameterList) // //{ // // ZPPFM010Response result010 = SAPDataLogic.HGSAPDK_ZPPFM010(sapParameter010, yyyymmdd); // // //sre.Message = result010.ZMSG; // // sre.Message = $"{result010.ZMSG}({sapParameter010.ZSUM})"; // // sre.Result = result010.ZTYPE; // // if (result010.TABLE_OUT != null && result010.TABLE_OUT.Length > 0) // // { // // // 保留条码同步履历 2020-10-14 by chenxy ztype = 'S' // // //sqlString = "update tsap_hegii_finishedproduct t set t.ZTime =sysdate, ZTYPE = nvl(:ZTYPE,'S'), ZMSG = :ZMSG where barcode=:barcode and sapflbatchno=:sapflbatchno"; // // sqlString = "update tsap_hegii_finishedproduct t set t.ZTime =sysdate, ZTYPE = 'D', ZMSG = :ZMSG where barcode=:barcode and ztype = 'S' and sapflbatchno=:sapflbatchno"; // // foreach (ZSPP110 item in result010.TABLE_OUT) // // { // // oracleParameter = new OracleParameter[] // // { // // new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item.ZTYPE, ParameterDirection.Input), // // new OracleParameter(":ZMSG",OracleDbType.Varchar2, item.ZMSG, ParameterDirection.Input), // // new OracleParameter(":barcode",OracleDbType.Varchar2, item.ZSCTM, ParameterDirection.Input), // // new OracleParameter(":sapflbatchno",OracleDbType.Varchar2, item.ZBZBS, ParameterDirection.Input), // // }; // // r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); // // } // // } // // if (result010.ZTYPE != "S") // // { // // sre.Result = -2; // // sre.Message = "同步条码失败," + result010.ZMSG; // // return sre; // // } // //} //} //else //{ #endregion sqlString = "update tsap_hegii_finishedproduct t set t.ZTime =sysdate, ZTYPE = 'D' where barcode=:barcode and ztype = 'S' and sapflbatchno=:sapflbatchno"; foreach (DataRow row in fpData.Rows) { oracleParameter = new OracleParameter[] { new OracleParameter(":barcode",OracleDbType.Varchar2, row["barcode"], ParameterDirection.Input), new OracleParameter(":sapflbatchno",OracleDbType.Varchar2, row["sapflbatchno"], ParameterDirection.Input), }; r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); } //} // 删除已同步条码 // 保留条码同步履历 2020-10-14 by chenxy ztype = 'S' //sql = "Delete from tsap_hegii_finishedproduct bar where 1 = 1" + fifter; //r = oracleTrConn.ExecuteNonQuery(sql); #endregion #region 同步产量 //Zppfm008 sapParameter = new Zppfm008(); if (workData != null && workData.Rows.Count > 0) { //sapParameter.ZSUM = workData.Rows.Count; //sapParameter.TABLE_IN = new ZSPP100[sapParameter.ZSUM]; sqlString = "insert into TSAP_HEGII_WorkData\n" + " (YYYYMMDD\n" + " ,WorkCode\n" + " ,DataCode\n" + " ,GoodsCode\n" + " ,SAPCode\n" + " ,UserCode\n" + " ,OutputNum\n" + " ,RECOVERYNUM\n" + " ,ORDERCODE\n" + " ,ORDERITEM\n" + " ,testmouldflag\n" + " ,zscs\n" + " ,LogID,createtime)\n" + "values\n" + " ('" + yyyymmdd + "'\n" + " ,'" + workcode + "'\n" + " ,'60'\n" + " ,:GoodsCode\n" + " ,:SAPCode\n" + " ,:UserCode\n" + " ,:OutputNum\n" + " ,:RECOVERYNUM\n" + " ,:ORDERCODE\n" + " ,:ORDERITEM\n" + " ,:testmouldflag\n" + " ,:zscs\n" + " ," + logid + ",:createtime)"; int index = 0; //DateTime now = DateTime.Now; foreach (DataRow item in workData.Rows) { //ZSPP100 info100 = new ZSPP100(); //// 工厂 //info100.WERKS = workcode; //// 型号 //info100.GROES = item["GoodsCode"].ToString(); //// 物料编号 //info100.MATNR = item["SAPCode"].ToString(); //// 生产工号 //info100.ZGHNU = item["UserCode"].ToString(); //// 数据节点 //info100.ZJDNU = "60"; //// 时间戳 //info100.ZSCNU = yyyymmdd; //// 销售凭证 //info100.VBELN = item["ORDERCODE"].ToString().Trim(); //// 销售凭证项目 //info100.POSNR = item["ORDERITEM"].ToString(); //// 产量 //info100.ZCLNG = item["OutputNum"].ToString(); //// 损坯 //info100.ZSPNG = "0"; //// 清除 //info100.ZQCNG = "0"; //// 回收 //info100.ZHSNG = item["RECOVERYNUM"].ToString(); //// 干补 //info100.ZGBNG = "0"; //// 注浆类型 G高压 L普通 M粘接高压(三车间) //info100.ZSCS = item["ZSCS"].ToString(); //info100.ZKSSJ = now.ToString("HHmmss"); //info100.ZJSRQ = Convert.ToDecimal(now.ToString("yyyyMMddHHmmss")); oracleParameter = new OracleParameter[] { new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item["GoodsCode"], ParameterDirection.Input), new OracleParameter(":SAPCode",OracleDbType.Varchar2, item["SAPCode"], ParameterDirection.Input), new OracleParameter(":UserCode",OracleDbType.Varchar2, item["UserCode"], ParameterDirection.Input), new OracleParameter(":OutputNum",OracleDbType.Varchar2, item["OutputNum"], ParameterDirection.Input), new OracleParameter(":RECOVERYNUM",OracleDbType.Varchar2, item["RECOVERYNUM"], ParameterDirection.Input), new OracleParameter(":ORDERCODE",OracleDbType.Varchar2, item["ORDERCODE"], ParameterDirection.Input), new OracleParameter(":ORDERITEM",OracleDbType.Varchar2, item["ORDERITEM"], ParameterDirection.Input), new OracleParameter(":testmouldflag",OracleDbType.Varchar2, item["TESTMOULDFLAG"], ParameterDirection.Input), new OracleParameter(":ZSCS",OracleDbType.Varchar2, item["ZSCS"], ParameterDirection.Input), new OracleParameter(":createtime",OracleDbType.Date, item["createtime"], ParameterDirection.Input), }; r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); //sapParameter.TABLE_IN[index++] = info100; } } //else //{ // sapParameter.ZSUM = 0; // sapParameter.TABLE_IN = new ZSPP100[sapParameter.ZSUM]; //} ////2022年9月23日13:06:25 添加时间限制,10月1号零点整不再传输原接口产量数据 //// 当前时间 //if (dateTimeNow < setTime) //{ // //ZPPFM008Response result = SAPDataLogic.HGSAPDK_ZPPFM008(sapParameter, yyyymmdd, "60"); // ////if (result.Ztype == "E") // ////{ // //// sqlString = "update tsap_hegii_datalog t set t.EndTime = sysdate, DataStuts = 'E', DataMSG = DataMSG||:msg where logid = :logid"; // //// oracleParameter = new OracleParameter[] // //// { // //// new OracleParameter(":msg",OracleDbType.Varchar2, result.Zmsg, ParameterDirection.Input), // //// new OracleParameter(":logid",OracleDbType.Int32, logid, ParameterDirection.Input), // //// }; // //// r = oracleConn.ExecuteNonQuery(sqlString, oracleParameter); // ////} // ////else // //if (result.TABLE_OUT != null && result.TABLE_OUT.Length > 0) // //{ // // sqlString = "update TSAP_HEGII_WorkData t set t.ZTime =sysdate, ZTYPE = :ZTYPE, ZMSG = :ZMSG where logid = " + logid + // // " \n and YYYYMMDD='" + yyyymmdd + "' and WorkCode='" + workcode + // // "' and DataCode='60' and GoodsCode=:GoodsCode and SAPCode=:SAPCode and UserCode=:UserCode \n" + // // "and OrderCode=:OrderCode and OrderItem=:OrderItem"; // // foreach (ZSPP100 item in result.TABLE_OUT) // // { // // string posnr = item.POSNR.TrimStart('0'); // // oracleParameter = new OracleParameter[] // // { // // new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item.ZTYPE, ParameterDirection.Input), // // new OracleParameter(":ZMSG",OracleDbType.Varchar2, item.ZMSG, ParameterDirection.Input), // // new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item.GROES, ParameterDirection.Input), // // new OracleParameter(":SAPCode",OracleDbType.Varchar2, item.MATNR, ParameterDirection.Input), // // new OracleParameter(":UserCode",OracleDbType.Varchar2, item.ZGHNU, ParameterDirection.Input), // // new OracleParameter(":OrderCode",OracleDbType.Varchar2, (string.IsNullOrEmpty(item.VBELN) ? " " : item.VBELN), ParameterDirection.Input), // // new OracleParameter(":OrderItem",OracleDbType.Varchar2, (string.IsNullOrEmpty(posnr) ? "0" : posnr), ParameterDirection.Input), // // }; // // r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); // // } // // //:msg||chr(13)||DataMSG // // result.ZMSG = $"{result.ZMSG}({sapParameter.ZSUM})"; // // sqlString = "update tsap_hegii_datalog t set t.EndTime = sysdate, DataStuts = :DataStuts, DataMSG =nvl2(:msg,:msg||' '||chr(13)||DataMSG,DataMSG) where logid = :logid"; // // oracleParameter = new OracleParameter[] // // { // // new OracleParameter(":DataStuts",OracleDbType.Varchar2, result.ZTYPE, ParameterDirection.Input), // // new OracleParameter(":msg",OracleDbType.Varchar2, result.ZMSG, ParameterDirection.Input), // // new OracleParameter(":logid",OracleDbType.Int32, logid, ParameterDirection.Input), // // }; // // r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); // //} // //if (result.ZTYPE != "S") // //{ // // sre.Result = -2; // // sre.Message = "同步产量失败," + result.ZMSG; // // return sre; // //} // //sqlString = // //"UPDATE tp_pm_groutingdailydetail bar\n" + // //" SET bar.issync = NULL\n" + // //" WHERE 1 = 1" + fifter; // //r = oracleTrConn.ExecuteNonQuery(sqlString); //} //else { #region 调用新报工接口 workcode = "5000"; sqlString = @" SELECT TO_CHAR(SYSDATE, 'YYYYMMDD') AS YYYYMMDD, SYSDATE AS CREATETIME, TT.GOODSCODE GROES, TT.SAPCODE MATNR, TT.USERCODE ZGHNU, TT.ORDERCODE VBELN, TT.ORDERITEM POSNR, DECODE(TT.TESTMOULDFLAG, 0, 'C', 1, 'Y', '') ZSCMS, 'T' AS ZSCS, TO_CHAR(TT.OUTPUTNUM) AS ZCLNG, TO_CHAR(TT.RECOVERYNUM) AS ZHSNG, :WORKCODE WERKS, '60' ZJDNU, TO_CHAR(SYSDATE, 'YYYYMMDD') ZSCNU, TO_CHAR(SYSDATE, 'HH24MISS') ZKSSJ, TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') ZJSRQ, '0' ZSPNG, '0' ZQCNG, '0' ZGBNG, TO_CHAR(TT.WORKSHOP) ZSCCJ, '0' DATACODE, TT.CHARG FROM (SELECT T.GOODSCODE, T.SAPCODE, T.USERCODE, T.ORDERCODE, T.ORDERITEM, T.TESTMOULDFLAG, T.ZSCS, T.WORKSHOP, T.CHARG, 0 - SUM(DECODE(T.RECYCLINGFLAG, '1', 0, 1)) OUTPUTNUM, 0 - SUM(DECODE(T.RECYCLINGFLAG, '0', 0, 1)) RECOVERYNUM FROM (SELECT BAR.GOODSCODE, BAR.MATERIALCODE SAPCODE, GH.FHUSERCODE USERCODE, O.ORDERNO, BAR.RECYCLINGFLAG, BAR.TESTMOULDFLAG, DECODE(BAR.TESTMOULDFLAG ,'0' ,'' ,DECODE(G.GOODS_LINE_CODE, 'G', 'A', 'M', 'A', 'L', 'B', '')) AS ZSCS, CASE WHEN O.ORDERID IS NULL OR O.ORDERNO LIKE 'HEGII%' THEN ' ' WHEN INSTR(O.ORDERNO, '/') = 0 THEN TO_CHAR(O.ORDERNO) ELSE TO_CHAR(SUBSTR(O.ORDERNO, 1, INSTR(O.ORDERNO, '/') - 1)) END ORDERCODE -- 销售凭证 , CASE WHEN O.ORDERID IS NULL OR O.ORDERNO LIKE 'HEGII%' OR INSTR(O.ORDERNO, '/') = 0 THEN '0' WHEN INSTR(O.ORDERNO, '#') = 0 THEN TO_CHAR(SUBSTR(O.ORDERNO, INSTR(O.ORDERNO, '/') + 1)) ELSE TO_CHAR(SUBSTR(O.ORDERNO ,INSTR(O.ORDERNO, '/') + 1 ,INSTR(O.ORDERNO, '#') - INSTR(O.ORDERNO, '/') - 1)) END ORDERITEM, CASE WHEN (INSTR(BAR.GROUTINGLINECODE, 'A') = 1 OR INSTR(BAR.GROUTINGLINECODE, 'D') = 1) AND INSTR(GT.GOODSTYPECODE, '001002') = 1 THEN 1 WHEN (INSTR(BAR.GROUTINGLINECODE, 'B') = 1 OR INSTR(BAR.GROUTINGLINECODE, 'D') = 1) AND INSTR(GT.GOODSTYPECODE, '001001') = 1 THEN 2 WHEN INSTR(BAR.GROUTINGLINECODE, 'C') = 1 THEN 3 ELSE 9 END AS WORKSHOP, TO_CHAR(GH.FHTIME, 'yyyymm') AS CHARG FROM TP_PM_GROUTINGDAILYDETAIL BAR INNER JOIN TP_PM_FINISHEDPRODUCT GH ON BAR.GROUTINGDAILYDETAILID = GH.GROUTINGDAILYDETAILID INNER JOIN TP_MST_GOODS G ON G.GOODSID = BAR.GOODSID INNER JOIN TP_MST_GOODSTYPE GT ON GT.GOODSTYPEID = G.GOODSTYPEID LEFT JOIN TP_PM_ORDER O ON O.ORDERID = GH.FHORDERID WHERE 1 = 1 " + fifter + @") T GROUP BY T.GOODSCODE, T.SAPCODE, T.USERCODE, T.ORDERCODE, T.ORDERITEM, T.TESTMOULDFLAG, T.ZSCS, T.WORKSHOP, T.CHARG) TT WHERE TT.OUTPUTNUM <> 0 OR TT.RECOVERYNUM <> 0 ORDER BY TT.GOODSCODE, TT.SAPCODE, TT.USERCODE, TT.ORDERCODE, TT.ORDERITEM, TT.ZSCS, TT.WORKSHOP, TT.CHARG "; oracleParameter = new OracleParameter[] { new OracleParameter(":WORKCODE", workcode) }; DataTable workData5000 = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter); //string logid_bg = oracleTrConn.GetSqlResultToStr("select SEQ_TSAP_DATALOG_BG.Nextval from dual"); sqlString = "insert into tsap_hegii_datalog_bg\n" + " (LogID\n" + " ,LogType\n" + " ,BeginTime\n" + " ,YYYYMMDD\n" + " ,WorkCode\n" + " ,DataCode\n" + " ,DataStuts\n" + " ,DataMSG\n" + " ,DATALOGID\n" + " ,EXECUTEDATEBEGIN\n" + " ,EXECUTEDATEEND,SAPGUID)\n" + "values\n" + " (:LogID\n" + " ,'2'\n" + " ,sysdate\n" + " ,:YYYYMMDD\n" + " ,'5000'\n" + " ,'60'\n" + " ,'F'\n" + " ,:DataMSG\n" + " ,:LogID\n" + " ,sysdate\n" + " ,sysdate,sys_guid())"; oracleParameter = new OracleParameter[] { new OracleParameter(":LogID",OracleDbType.Int32, logid_bg, ParameterDirection.Input), new OracleParameter(":YYYYMMDD",OracleDbType.Varchar2, yyyymmdd, ParameterDirection.Input), new OracleParameter(":DataMSG",OracleDbType.Varchar2, "", ParameterDirection.Input), }; r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); sqlString = "insert into TSAP_HEGII_WORKDATA_BG\n" + " (YYYYMMDD\n" + " ,WorkCode\n" + " ,DataCode\n" + " ,GoodsCode\n" + " ,SAPCode\n" + " ,UserCode\n" + " ,WORKSHOP\n" + " ,OutputNum\n" + " ,RECOVERYNUM\n" + " ,ORDERCODE\n" + " ,ORDERITEM\n" + " ,testmouldflag\n" + " ,zscs\n" + " ,LogID,createtime,workdataid,charg)\n" + "values\n" + " ('" + yyyymmdd + "'\n" + " ,'5000'\n" + " ,'60'\n" + " ,:GoodsCode\n" + " ,:SAPCode\n" + " ,:UserCode\n" + " ,:ZSCCJ\n" + " ,:OutputNum\n" + " ,:RECOVERYNUM\n" + " ,:ORDERCODE\n" + " ,:ORDERITEM\n" + " ,:testmouldflag\n" + " ,:zscs\n" + " ," + logid_bg + ",:createtime,:workdataid,:charg)"; //DateTime now = DateTime.Now; foreach (DataRow item in workData5000.Rows) { string workdataid = oracleTrConn.GetSqlResultToStr("select SEQ_HEGII_WORKDATA_BG.Nextval from dual"); oracleParameter = new OracleParameter[] { new OracleParameter(":GoodsCode", item["GROES"].ToString()), new OracleParameter(":SAPCode", item["MATNR"].ToString()), new OracleParameter(":UserCode", item["ZGHNU"].ToString()), new OracleParameter(":ZSCCJ", item["ZSCCJ"].ToString()), new OracleParameter(":OutputNum", item["ZCLNG"].ToString()), new OracleParameter(":RECOVERYNUM", item["ZHSNG"].ToString()), new OracleParameter(":ORDERCODE", item["VBELN"].ToString()), new OracleParameter(":ORDERITEM", item["POSNR"].ToString()), new OracleParameter(":testmouldflag", item["ZSCMS"].ToString()), new OracleParameter(":zscs", item["ZSCS"].ToString()), new OracleParameter(":createtime", OracleDbType.Date,item["createtime"], ParameterDirection.Input), new OracleParameter(":workdataid", workdataid), new OracleParameter(":charg", item["CHARG"].ToString()), }; r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); } sqlString = "SELECT TO_CHAR(wd.yyyymmdd) yyyymmdd\n" + " ,TO_CHAR(5000) WERKS\n" + " ,TO_CHAR(wd.goodscode) GROES\n" + " ,TO_CHAR(wd.sapcode) MATNR\n" + " ,TO_CHAR(wd.usercode) ZGHNU\n" + " ,TO_CHAR(wd.datacode) ZJDNU\n" + " ,to_char(sysdate, 'YYYYMMDD' ) ZSCNU\n" + " ,to_char(sysdate, 'HH24MISS' ) ZKSSJ\n" + " ,to_char(sysdate, 'YYYYMMDDHH24MISS' ) ZJSRQ\n" + " ,TO_CHAR(wd.ordercode) VBELN\n" + " ,TO_CHAR(wd.orderitem) POSNR\n" + " ,TO_CHAR(wd.outputnum) ZCLNG\n" + " ,TO_CHAR(wd.scrapnum) ZSPNG\n" + " ,TO_CHAR(wd.cleanupnum) ZQCNG\n" + " ,TO_CHAR(wd.recoverynum) ZHSNG\n" + " ,TO_CHAR(wd.repairnum) ZGBNG\n" + " ,TO_CHAR(wd.testmouldflag) ZSCMS\n" + " -- ,TO_CHAR(wd.zscs) zscs\n" + " ,'T' AS zscs\n" + " ,TO_CHAR(wd.WORKSHOP) ZSCCJ\n" + " ,WD.CHARG\n" + " ,TO_CHAR(60) datacode\n" + " ,'5000' || LPAD(DL.LOGID, 10,'0') AS ZID\n" + " FROM tsap_hegii_workdata_bg wd\n" + " INNER JOIN TSAP_HEGII_DATALOG_BG DL\n" + " ON wd.LOGID = DL.LOGID \n" + " WHERE wd.logid = :logid"; OracleParameter[] par = null; par = new OracleParameter[] { new OracleParameter(":logid", OracleDbType.Int32, logid_bg, ParameterDirection.Input), }; DataTable dtt = oracleTrConn.GetSqlResultToDt(sqlString, par); int num = dtt.Rows.Count; //string sq = "select SAP_INI_BG from TP_SYS_SAPCONFIG"; //string SAP_ING_NEW = oracleTrConn.GetSqlResultToStr(sq); //if (true) //{ // 调用SAP接口 string postString = "{\"ZSUM\":" + num.ToString() + ",\"TABLE_IN\":{\"item\":" + JsonHelper.ToJson(ModelConvertHelper.ConvertToModel(dtt)) + "}}"; INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII); string url030 = ini.ReadIniData("SAP_NEW_INFO", "Url030"); //string url030 = "http://hgs4podev.hegii.com:50200/RESTAdapter/DKMES/ZPPFM030"; string result = string.Empty; try { result = SAPDataLogic.PostData(url030, postString, "POST"); } catch (Exception ex) { sre.Result = -2; sre.Message = "sap030接口同步失败," + ex.Message; return sre; } if (JObject.Parse(result)["TABLE_OUT"] != null && JObject.Parse(result)["TABLE_OUT"].ToString().Length > 0) { sqlString = "update TSAP_HEGII_WorkData_bg t set t.ZTime =sysdate, ZTYPE = :ZTYPE, ZMSG = :ZMSG where logid = " + logid_bg + " \n and YYYYMMDD='" + yyyymmdd + "' and WorkCode='" + workcode + "' and DataCode='60' and GoodsCode=:GoodsCode and SAPCode=:SAPCode and UserCode=:UserCode \n" + "and OrderCode=:OrderCode and OrderItem=:OrderItem"; Dictionary obj = JsonConvert.DeserializeObject>(result); object TABLE_OUT; obj.TryGetValue("TABLE_OUT", out TABLE_OUT); obj = JsonConvert.DeserializeObject>(TABLE_OUT + ""); object item1; obj.TryGetValue("item", out item1); JArray arr = JArray.FromObject(item1); foreach (JObject item60 in arr) { string posnr = item60["POSNR"].ToString().TrimStart('0'); oracleParameter = new OracleParameter[] { new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item60["ZTYPE"].ToString(), ParameterDirection.Input), new OracleParameter(":ZMSG",OracleDbType.Varchar2, item60["ZMSG"].ToString(), ParameterDirection.Input), new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item60["GROES"].ToString(), ParameterDirection.Input), new OracleParameter(":SAPCode",OracleDbType.Varchar2, item60["MATNR"].ToString(), ParameterDirection.Input), new OracleParameter(":UserCode",OracleDbType.Varchar2, item60["ZGHNU"].ToString(), ParameterDirection.Input), new OracleParameter(":OrderCode",OracleDbType.Varchar2, (string.IsNullOrEmpty(item60["VBELN"].ToString()) ? " " : item60["VBELN"].ToString()), ParameterDirection.Input), new OracleParameter(":Orderitem",OracleDbType.Varchar2, ((string.IsNullOrEmpty(posnr)) ? "0" : posnr), ParameterDirection.Input), }; r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); } //:msg||chr(13)||DataMSG JObject.Parse(result)["ZMSG"] = $"{JObject.Parse(result)["ZMSG"]}({num})"; sqlString = "update tsap_hegii_datalog_bg t set t.EndTime = sysdate, DataStuts = :DataStuts, DataMSG =nvl2(:msg,:msg||' '||chr(13)||DataMSG,DataMSG) where logid = :logid"; oracleParameter = new OracleParameter[] { new OracleParameter(":DataStuts",OracleDbType.Varchar2, JObject.Parse(result)["ZTYPE"].ToString(), ParameterDirection.Input), new OracleParameter(":msg",OracleDbType.Varchar2, JObject.Parse(result)["ZMSG"].ToString(), ParameterDirection.Input), new OracleParameter(":logid",OracleDbType.Int32, logid_bg, ParameterDirection.Input), }; r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); } if (JObject.Parse(result)["ZTYPE"].ToString() != "S") { sre.Result = -2; sre.Message = "同步产量失败," + JObject.Parse(result)["ZMSG"].ToString(); return sre; } #endregion //sqlString = //"UPDATE tp_pm_groutingdailydetail bar\n" + //" SET bar.issync = '1'\n" + //" WHERE 1 = 1" + fifter; //r = oracleTrConn.ExecuteNonQuery(sqlString); //} //} #endregion #endregion #region 产成品交接撤销 // 本批交接的批次号 for (int i = 0; i < dtData.Rows.Count; i++) { #region 查询产品相关信息 // 撤销记录 sql = "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,dtData.Rows[i]["barcode"],ParameterDirection.Input), new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input), }; int resultRow = oracleTrConn.ExecuteNonQuery(sql, Paras); // SAP同步后再成品交接撤销的,记录撤销标识 string sapsql = null; //string sapsql = "select count(*) from tsap_hegii_FinishedProduct t where t.barcode = :BarCode and ztype='S' and rownum=1 "; OracleParameter[] sapparas = new OracleParameter[] { new OracleParameter(":BarCode",OracleDbType.NVarchar2,dtData.Rows[i]["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); } // 保留条码同步履历 2020-10-14 by chenxy ztype = 'S' //sapsql = "update tsap_hegii_FinishedProduct set ztype = 'D' where barcode=:BarCode and (ztype is null or ztype not in ('S','D'))"; //sapsql = "update tsap_hegii_FinishedProduct set ztype = 'D' where barcode=:BarCode and (ztype is null or ztype = 'S')"; 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); #endregion } #endregion #region 同步WMS系统 if (fpData.Rows.Count > 0) { DateTime now = DateTime.Now; string message = WMSDataLogic.BackPushWMS(fpData, now); // 同步日志 sqlString = @" INSERT INTO TP_WMS_LOG (LOGTYPE, SPS, SKU, SERIALNO, ADDDAY, ADDTIME, CODEI, UDF1, UDF2, LPN, RETURNDESC, ACCOUNTID, CREATETIME, UPDATETIME, CREATEUSERID, UPDATEUSERID) VALUES (:LOGTYPE, :SPS, :SKU, :SERIALNO, :ADDDAY, :ADDTIME, :CODEI, :UDF1, :UDF2, :LPN, :RETURNDESC, :ACCOUNTID, :CREATETIME, :CREATETIME, :USERID, :USERID) "; string orderitem; foreach (DataRow row in fpData.Rows) { orderitem = row["orderitem"] + ""; if (string.IsNullOrEmpty(orderitem) || "0".Equals(orderitem)) { orderitem = "000000"; } oracleParameter = new OracleParameter[] { new OracleParameter(":LOGTYPE",OracleDbType.Int32, 2, ParameterDirection.Input), new OracleParameter(":SPS",OracleDbType.Varchar2, "5020", ParameterDirection.Input), new OracleParameter(":SKU",OracleDbType.Varchar2, row["sapcode"], ParameterDirection.Input), new OracleParameter(":SERIALNO",OracleDbType.Varchar2, row["outcode"], ParameterDirection.Input), new OracleParameter(":ADDDAY",OracleDbType.Varchar2, now.ToString("yyyyMMdd"), ParameterDirection.Input), new OracleParameter(":ADDTIME",OracleDbType.Varchar2, now.ToString("HHmmss"), ParameterDirection.Input), new OracleParameter(":CODEI",OracleDbType.Varchar2, row["barcode"], ParameterDirection.Input), new OracleParameter(":UDF1",OracleDbType.Varchar2, row["ordercode"], ParameterDirection.Input), new OracleParameter(":UDF2",OracleDbType.Varchar2, orderitem, ParameterDirection.Input), new OracleParameter(":LPN",OracleDbType.Varchar2, row["sapflbatchno"], ParameterDirection.Input), new OracleParameter(":RETURNDESC",OracleDbType.Varchar2, message, ParameterDirection.Input), new OracleParameter(":ACCOUNTID",OracleDbType.Varchar2, sUserInfo.AccountID, ParameterDirection.Input), new OracleParameter(":CREATETIME",OracleDbType.Date, now, ParameterDirection.Input), new OracleParameter(":USERID",OracleDbType.Varchar2, sUserInfo.UserID, ParameterDirection.Input), }; r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter); } sqlString = "UPDATE tp_pm_groutingdailydetail bar\n" + " SET bar.issync = NULL\n" + " WHERE 1 = 1" + fifter; r = oracleTrConn.ExecuteNonQuery(sqlString); } #endregion #region 回收包材库库存 sqlString = "SELECT 1\n" + " FROM tp_pm_groutingdailydetail bar\n" + " WHERE bar.packingby3 = '1' " + fifter; isExists = oracleTrConn.GetSqlResultToObj(sqlString); if (isExists != null) { //INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII); string packingURL = ini.ReadIniData("SAP_HEGII", "PackingURL"); foreach (DataRow row in workData.Rows) { string url = packingURL + row["sapcode"] + "&num=" + row["outputnum"]; WebRequest req = WebRequest.Create(url); req.Method = "GET"; Stream stream = req.GetResponse().GetResponseStream(); StreamReader reader = new StreamReader(stream); JObject json = JObject.Parse(reader.ReadToEnd()); // 包材库失败暂时不处理 TODO if (json["success"].ToString() == "false") { //sre.Result = -2; //sre.Message = json["message"].ToString(); //return sre; } } } #endregion sre.Result = 1; oracleTrConn.Commit(); oracleTrConn.Disconnect(); return sre; } 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 /// /// 撤销产成品交接 /// /// /// /// 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 ztype='S' 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); } sapsql = "update tsap_hegii_FinishedProduct set ztype = 'D' where barcode=:BarCode and (ztype is null or ztype not in ('S','D'))"; 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().ToUpper(); // 条码信息 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 = "报损待审产品不能回收"; } // chenxy 2019-10-02 半检返修 IsReworkFlag=2 else if (Convert.ToInt32(dsNew.Tables[0].Rows[0]["ISREWORKFLAG"]) == 1) { errorMessage = "半检返工中不能回收"; } else if (Convert.ToInt32(dsNew.Tables[0].Rows[0]["ISREWORKFLAG"]) == 2) { 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; } } /// /// 按条码判定是否为首节点 /// 从TP_PM_GroutingDailyDetail表中的BEGINNINGFLAG字段判定是否为首节点 /// "0":非首节点,"1":首节点 /// /// 数据连接 /// 条码 /// 是否首节点 /// xuwei add 2019-09-23 //public static bool IsNodeBegin(IDBTransaction oracleTrConn, string barCode) //{ // bool result = false; // try // { // if (barCode != "") // { // string flag = oracleTrConn.GetSqlResultToStr($@"select BEGINNINGFLAG as flag // from TP_PM_GroutingDailyDetail // where BARCODE = {barCode}"); // if (flag == "") throw new Exception("条码无效!请检查!"); // result = flag == "0" ? true : false; // } // } // catch (Exception ex) // { // throw ex; // } // return result; //} //public static bool IsNodeBegin(IDBConnection oracleTrConn, string barCode) //{ // bool result = false; // try // { // if (barCode != "") // { // string flag = oracleTrConn.GetSqlResultToStr($@"select BEGINNINGFLAG as flag // from TP_PM_GroutingDailyDetail // where BARCODE = {barCode}"); // if (flag == "") throw new Exception("条码无效!请检查!"); // result = flag == "0" ? true : false; // } // } // catch (Exception ex) // { // throw ex; // } // return result; //} /// /// 按条码判定是否为首节点(调整为复用方法) /// 从TP_PM_GroutingDailyDetail表中的BEGINNINGFLAG字段判定是否为首节点 /// "0":非首节点,"1":首节点,"-1":条码无效 /// /// 数据连接 /// 条码 /// 是否首节点 /// xuwei add 2019-09-26 public static int IsNodeBegin(T oracleTrConn, string barCode) { Type t = typeof(T); int result = -1; try { if (barCode != "") { OracleParameter[] parasNew = new OracleParameter[]{ new OracleParameter(":barcode",barCode) }; string flag = t.GetMethod("GetSqlResultToStr") .Invoke(oracleTrConn, new object[] { $@"select BEGINNINGFLAG as flag from TP_PM_GroutingDailyDetail where BARCODE = :barcode", parasNew }).ToString(); //if (flag == "") throw new Exception("无效条码,请检查!"); //xuwei fix 2019-09-26 找不到和非首节点均返回0 // 返修指定首节点时,判断错误 if (string.IsNullOrWhiteSpace(flag)) { return -1; } result = (flag == "0" ? 1 : 0); } } catch (Exception ex) { throw ex; } return result; } #region 保存用到的 /// /// 校验条码是否允许撤销,如果不允许提示错误消息 /// /// 原时间 /// 允许撤销天数 /// 设置code,用于返回不同错误消息 /// /// public static ServiceResultEntity BarcodeAllowCancel(DateTime orgTime, int days, string settingCode, SUserInfo sUserInfo) { IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { ServiceResultEntity resultEntity = new ServiceResultEntity(); orgTime = orgTime.Date; // 取日期部分 DateTime currentTime = DateTime.Now.Date; // 参数验证用服务端当前设置 string sqlString = "SELECT sst.settingvalue\n" + " FROM tp_mst_systemsetting sst\n" + " WHERE sst.accountid = " + sUserInfo.AccountID + "\n" + " AND sst.settingcode = '" + settingCode + "'"; string strValue = oracleConn.GetSqlResultToStr(sqlString); int pDays = 0; if (int.TryParse(strValue, out pDays)) { days = pDays; } if (days == 0) { // 表示可以撤销 resultEntity.Result = 1; return resultEntity; } if (orgTime > currentTime.AddDays(-days)) { // 表示可以撤销 resultEntity.Result = 1; } else { resultEntity.Result = -1; // 提示不同错误消息 if (settingCode.Equals(Constant.SettingType.S_PM_002.ToString())) { //交坯限制天数 resultEntity.Message = string.Format(Messages.MSG_S_PM_002, orgTime.ToString("yyyy-MM-dd"), days.ToString(), orgTime.AddDays(days - 1).ToString("yyyy-MM-dd")); } else if (settingCode.Equals(Constant.SettingType.S_PM_003.ToString())) { //交坯撤销限制天数 resultEntity.Message = string.Format(Messages.MSG_S_PM_003, orgTime.ToString("yyyy-MM-dd"), days.ToString(), orgTime.AddDays(days - 1).ToString("yyyy-MM-dd")); } else if (settingCode.Equals(Constant.SettingType.S_PM_004.ToString())) { //计件撤销限制天数 resultEntity.Message = string.Format(Messages.MSG_S_PM_004, orgTime.ToString("yyyy-MM-dd"), days.ToString(), orgTime.AddDays(days - 1).ToString("yyyy-MM-dd")); } else if (settingCode.Equals(Constant.SettingType.S_PM_005.ToString())) { //成品撤销限制天数 resultEntity.Message = string.Format(Messages.MSG_S_PM_005, orgTime.ToString("yyyy-MM-dd"), days.ToString(), orgTime.AddDays(days - 1).ToString("yyyy-MM-dd")); } else if (settingCode.Equals(Constant.SettingType.S_PM_006.ToString())) { //损坯撤销限制天数 resultEntity.Message = string.Format(Messages.MSG_S_PM_006, orgTime.ToString("yyyy-MM-dd"), days.ToString(), orgTime.AddDays(days - 1).ToString("yyyy-MM-dd")); } else if (settingCode.Equals(Constant.SettingType.S_PM_007.ToString())) { //半检登记改判限制天数 resultEntity.Message = string.Format(Messages.MSG_S_PM_007, orgTime.ToString("yyyy-MM-dd"), days.ToString(), orgTime.AddDays(days - 1).ToString("yyyy-MM-dd")); } else if (settingCode.Equals(Constant.SettingType.S_PM_008.ToString())) { //半检复检撤销限制天数 resultEntity.Message = string.Format(Messages.MSG_S_PM_008, orgTime.ToString("yyyy-MM-dd"), days.ToString(), orgTime.AddDays(days - 1).ToString("yyyy-MM-dd")); } else if (settingCode.Equals(Constant.SettingType.S_PM_009.ToString())) { //成检登记改判限制天数 resultEntity.Message = string.Format(Messages.MSG_S_PM_009, orgTime.ToString("yyyy-MM-dd"), days.ToString(), orgTime.AddDays(days - 1).ToString("yyyy-MM-dd")); } } return resultEntity; } catch (Exception ex) { throw ex; } finally { if (oracleConn.ConnState == ConnectionState.Open) { oracleConn.Close(); } } } /// /// 构建 计数/检验时返回的信息 /// /// public static DataTable CreateBarCodeResultTable() { // 注意:更新表字段时,一定把后续引用的字段全部更新一遍 DataTable barCodeResultTable = new DataTable("BarCodeTable"); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_errMsg.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_goodsID.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_goodsCode.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_goodsName.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_groutingUserName.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_groutingUserID.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_groutingNum.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_mouldCode.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_groutingdate.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_isReFire.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_missFlag.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_logoID.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_logoCode.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_logoName.ToString()); //xuwei add 2020-03-04 添加釉料属性 barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_glazeName.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_deliverLimitCycle.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_barcode.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_WaterLabelCode.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_CodeCheckFlag.ToString()); //漏气标识 内漏标识 xuwei add 2020-06-11 barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_LeakFlag1.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_LeakFlag2.ToString()); //增加重烧名称等相关列 fubin add 2020-06-30 barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_LeakFlag3.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_specialRepairFlagName.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_isReFireName.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_LeakFlag1Name.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_LeakFlag2Name.ToString()); barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_LeakFlag3Name.ToString()); // 包装装板用 barCodeResultTable.Columns.Add("GOODSMODELforCheck"); // 最大装板数量 barCodeResultTable.Columns.Add("PlateLimitNum", typeof(int)); //所在工序 barCodeResultTable.Columns.Add("ProcedureName", typeof(string)); barCodeResultTable.Columns.Add("FinishedCheckProcedureid", typeof(int)); barCodeResultTable.Columns.Add("procedureID", typeof(int)); barCodeResultTable.Columns.Add("DefectFlagID", typeof(int)); return barCodeResultTable; } /// /// 检验条码(除了交坯单点检验) /// /// 工序ID /// 产品条码 /// DataSet public static DataSet CheckBarcodeSinglePoint(int procedureID, string barcode, SUserInfo sUserInfo) { IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { oracleConn.Open(); DataTable dtBarCode = CreateBarCodeResultTable(); DataSet returnDs = new DataSet(); DataRow dr = dtBarCode.NewRow(); string sqlBarcode = GetConvertBarCode(oracleConn, barcode, procedureID, sUserInfo); if (sqlBarcode == string.Empty) { dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "无效条码"; dr[Constant.BarCodeResultTableColumns.out_missFlag.ToString()] = 0; dtBarCode.Rows.Add(dr); returnDs.Tables.Add(dtBarCode); return returnDs; } else { dr[Constant.BarCodeResultTableColumns.out_barcode.ToString()] = sqlBarcode; barcode = sqlBarcode; } OracleParameter[] paras = new OracleParameter[]{ new OracleParameter("in_procedureid",OracleDbType.Int32,procedureID,ParameterDirection.Input), new OracleParameter("in_barcode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input), new OracleParameter("out_errMsg",OracleDbType.NVarchar2,2000,null,ParameterDirection.Output), new OracleParameter("out_goodsID",OracleDbType.Int32,ParameterDirection.Output), new OracleParameter("out_goodsCode",OracleDbType.NVarchar2,50,null,ParameterDirection.Output), new OracleParameter("out_goodsName",OracleDbType.NVarchar2,50,null,ParameterDirection.Output), new OracleParameter("out_groutingUserCode",OracleDbType.NVarchar2,50,null,ParameterDirection.Output), new OracleParameter("out_errMsg_Status",OracleDbType.Varchar2,50,"",ParameterDirection.Output), }; oracleConn.ExecStoredProcedure("PRO_PM_CheckBarcode", paras); dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = paras[2].Value.ToString() == "null" ? "" : paras[2].Value.ToString().Replace("\\n\\r", "\n\r"); int missFlag = 0; if (paras[7].Value != null && paras[7].Value.ToString() == "1") { missFlag = AddBarCodeMissing(oracleConn, barcode, procedureID, sUserInfo); } dr[Constant.BarCodeResultTableColumns.out_goodsID.ToString()] = paras[3].Value.ToString() == "null" ? 0 : paras[3].Value; dr[Constant.BarCodeResultTableColumns.out_goodsCode.ToString()] = paras[4].Value.ToString() == "null" ? "" : paras[4].Value; dr[Constant.BarCodeResultTableColumns.out_goodsName.ToString()] = paras[5].Value.ToString() == "null" ? "" : paras[5].Value; dr[Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()] = paras[6].Value.ToString() == "null" ? 0 : paras[6].Value; dr[Constant.BarCodeResultTableColumns.out_missFlag.ToString()] = missFlag; if (paras[7].Value.ToString() == "null") //只有正确的条码,读注浆信息 { // string sqlString = @"select // TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode, // tp_pm_groutingdailydetail.groutingcount as GroutingNum, // tp_pm_groutingdailydetail.GroutingMouldCode as MouldCode, // tp_pm_groutingdailydetail.ispublicbody, // tp_pm_groutingdailydetail.Groutingdate, // tp_pm_groutingdailydetail.SpecialRepairFlag // from tp_pm_groutingdailydetail // where tp_pm_groutingdailydetail.GroutingDailyDetailID in (select GroutingDailyDetailID from TP_PM_UsedBarCode where barcode=:barcode)"; string sqlString = "SELECT PI.GROUTINGUSERCODE,\n" + " PI.GROUTINGNUM,\n" + " PI.GROUTINGMOULDCODE AS MOULDCODE,\n" + " PI.ISPUBLICBODY,\n" + " PI.GROUTINGDATE,\n" + " PI.SPECIALREPAIRFLAG,\n" + " L.LOGOID,\n" + " L.LOGOCODE,\n" + " L.LOGONAME,\n" + //" GOODS.WATERLABELCODE\n" + " nvl((select gls.WATERLABELCODE\n" + " from TP_MST_GOODSLOGOSAP gls\n" + " where gls.goodsid = PI.goodsid\n" + " and gls.logoid = PI.LOGOID)\n" + " ,GOODS.WATERLABELCODE) WATERLABELCODE\n" + " FROM TP_PM_INPRODUCTION PI\n" + " LEFT JOIN TP_MST_LOGO L\n" + " ON PI.LOGOID = L.LOGOID\n" + " LEFT JOIN TP_MST_GOODS GOODS\n" + " ON PI.GOODSID = GOODS.GOODSID\n" + " WHERE PI.BARCODE = :BARCODE"; paras = new OracleParameter[] { new OracleParameter(":BARCODE",barcode) }; DataSet ds = oracleConn.GetSqlResultToDs(sqlString, paras); if (ds != null && ds.Tables[0].Rows.Count > 0) { dr[Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()] = ds.Tables[0].Rows[0]["GROUTINGUSERCODE"].ToString(); dr[Constant.BarCodeResultTableColumns.out_groutingNum.ToString()] = ds.Tables[0].Rows[0]["GROUTINGNUM"].ToString(); dr[Constant.BarCodeResultTableColumns.out_mouldCode.ToString()] = ds.Tables[0].Rows[0]["MOULDCODE"].ToString(); dr[Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()] = ds.Tables[0].Rows[0]["ISPUBLICBODY"].ToString(); dr[Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()] = "0"; dr[Constant.BarCodeResultTableColumns.out_groutingdate.ToString()] = ds.Tables[0].Rows[0]["GROUTINGDATE"].ToString(); dr[Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()] = ds.Tables[0].Rows[0]["SPECIALREPAIRFLAG"].ToString(); dr[Constant.BarCodeResultTableColumns.out_isReFire.ToString()] = "0"; dr[Constant.BarCodeResultTableColumns.out_logoID.ToString()] = ds.Tables[0].Rows[0]["LOGOID"].ToString(); dr[Constant.BarCodeResultTableColumns.out_logoCode.ToString()] = ds.Tables[0].Rows[0]["LOGOCODE"].ToString(); dr[Constant.BarCodeResultTableColumns.out_logoName.ToString()] = ds.Tables[0].Rows[0]["LOGONAME"].ToString(); dr[Constant.BarCodeResultTableColumns.out_WaterLabelCode.ToString()] = ds.Tables[0].Rows[0]["WATERLABELCODE"].ToString(); // 获取编码检验标识 sqlString = "SELECT CODECHECKFLAG FROM TP_PC_PROCEDURE WHERE PROCEDUREID = :PROCEDUREID"; paras = new OracleParameter[] { new OracleParameter(":PROCEDUREID",procedureID) }; DataTable dt = oracleConn.GetSqlResultToDt(sqlString, paras); if (dt != null && dt.Rows.Count > 0) { dr[Constant.BarCodeResultTableColumns.out_CodeCheckFlag.ToString()] = dt.Rows[0]["CODECHECKFLAG"] + ""; } } } dtBarCode.Rows.Add(dr); returnDs.Tables.Add(dtBarCode); return returnDs; } catch (Exception ex) { throw ex; } finally { if (oracleConn.ConnState == ConnectionState.Open) { oracleConn.Close(); } } } /// /// 交坯验证条码 /// /// 工序ID /// 产品条码 /// DataSet public static DataSet CheckBarcodeDeliverMudSinglePoint(int procedureID, string barcode, SUserInfo sUserInfo, ref int? GroutingDailyDetailID) { IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { oracleConn.Open(); 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 = oracleConn.GetSqlResultToDs(sql, paras); DataTable dtBarCode = CreateBarCodeResultTable(); DataSet returnDs = new DataSet(); DataRow dr = dtBarCode.NewRow(); dr[Constant.BarCodeResultTableColumns.out_barcode.ToString()] = barcode; if (ds != null && ds.Tables[0].Rows.Count == 0) { dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "无效条码[" + barcode + "]"; } 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 = oracleConn.GetSqlResultToStr(sql); dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "条码已被替换,新条码为" + newbarcode; } else if (ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "2") { dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "产品已成型报损"; } // else if (ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "3" || ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "4") { //dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "产品已交坯"; dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "产品已在产"; } else if (ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "1") { dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = ""; // string sqlString = @"select // TP_PM_GroutingDailyDetail.GoodsID, // TP_PM_GroutingDailyDetail.GoodsCode, // TP_PM_GroutingDailyDetail.GoodsName, // TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode, // tp_pm_groutingdailydetail.groutingcount as GroutingNum, // tp_pm_groutingdailydetail.GroutingMouldCode as MouldCode, // tp_pm_groutingdailydetail.ispublicbody, // tp_pm_groutingdailydetail.Groutingdate, // tp_pm_groutingdailydetail.SpecialRepairFlag // from TP_PM_USEDBARCODE // left join // tp_pm_groutingdailydetail // on TP_PM_USEDBARCODE.groutingdailydetailid=tp_pm_groutingdailydetail.groutingdailydetailid // where tp_pm_groutingdailydetail.BarCode=:barcode"; GroutingDailyDetailID = Convert.ToInt32(ds.Tables[0].Rows[0]["GroutingDailyDetailid"].ToString()); string sqlString = @"select tp_pm_GroutingDailyDetail.groutingdailydetailid, tp_pm_GroutingDailyDetail.GoodsID, tp_pm_GroutingDailyDetail.GoodsCode, tp_pm_GroutingDailyDetail.GoodsName, tp_pm_GroutingDailyDetail.UserCode as GroutingUserCode, tp_pm_GroutingDailyDetail.groutingcount as GroutingNum, tp_pm_GroutingDailyDetail.GroutingMouldCode as MouldCode, tp_pm_GroutingDailyDetail.ispublicbody, tp_pm_GroutingDailyDetail.Groutingdate, tp_pm_GroutingDailyDetail.SpecialRepairFlag, tp_mst_logo.logoid, tp_mst_logo.logocode, tp_mst_logo.logoname from tp_pm_GroutingDailyDetail left join tp_mst_logo on tp_mst_logo.logoid=tp_pm_GroutingDailyDetail.logoid where tp_pm_GroutingDailyDetail.groutingdailydetailid=:groutingdailydetailid"; //where tp_pm_GroutingDailyDetail.barcode=:barcode"; paras = new OracleParameter[]{ new OracleParameter(":groutingdailydetailid",ds.Tables[0].Rows[0]["GroutingDailyDetailid"].ToString()), //new OracleParameter("barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input), }; ds = oracleConn.GetSqlResultToDs(sqlString, paras); if (ds != null && ds.Tables[0].Rows.Count > 0) { GroutingDailyDetailID = Convert.ToInt32(ds.Tables[0].Rows[0]["GroutingDailyDetailid"].ToString()); 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 = oracleConn.GetSqlResultToDs(sqlExistGoods, paras); if (dsGoods.Tables[0].Rows[0][0].ToString() != "1") { dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = @"条码[" + barcode + "]不可以经过该工序\n\r原因:条码对应的产品编码[" + ds.Tables[0].Rows[0]["GoodsCode"].ToString() + "]没有在该工序中配置"; } else { dr[Constant.BarCodeResultTableColumns.out_goodsID.ToString()] = ds.Tables[0].Rows[0]["GoodsID"].ToString(); dr[Constant.BarCodeResultTableColumns.out_goodsCode.ToString()] = ds.Tables[0].Rows[0]["GoodsCode"].ToString(); dr[Constant.BarCodeResultTableColumns.out_goodsName.ToString()] = ds.Tables[0].Rows[0]["GoodsName"].ToString(); dr[Constant.BarCodeResultTableColumns.out_missFlag.ToString()] = 0; dr[Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()] = ds.Tables[0].Rows[0]["GroutingUserCode"].ToString(); dr[Constant.BarCodeResultTableColumns.out_groutingNum.ToString()] = ds.Tables[0].Rows[0]["GroutingNum"].ToString(); dr[Constant.BarCodeResultTableColumns.out_mouldCode.ToString()] = ds.Tables[0].Rows[0]["MouldCode"].ToString(); dr[Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()] = ds.Tables[0].Rows[0]["ispublicbody"].ToString(); dr[Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()] = "0"; dr[Constant.BarCodeResultTableColumns.out_groutingdate.ToString()] = ds.Tables[0].Rows[0]["Groutingdate"].ToString(); dr[Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()] = ds.Tables[0].Rows[0]["SpecialRepairFlag"].ToString(); dr[Constant.BarCodeResultTableColumns.out_isReFire.ToString()] = "0"; dr[Constant.BarCodeResultTableColumns.out_logoID.ToString()] = ds.Tables[0].Rows[0]["logoid"].ToString(); dr[Constant.BarCodeResultTableColumns.out_logoCode.ToString()] = ds.Tables[0].Rows[0]["logoCode"].ToString(); dr[Constant.BarCodeResultTableColumns.out_logoName.ToString()] = ds.Tables[0].Rows[0]["logoName"].ToString(); } } } } dr[Constant.BarCodeResultTableColumns.out_missFlag.ToString()] = 0; dtBarCode.Rows.Add(dr); returnDs.Tables.Add(dtBarCode); return returnDs; } catch (Exception ex) { throw ex; } finally { if (oracleConn.ConnState == ConnectionState.Open) { oracleConn.Close(); } } } /// /// 根据条码及工序判断是否漏扫 /// /// 产品条码 /// 校验工序ID /// 用户基本信息 /// DataSet public static string GetConvertBarCode(IDBConnection oracleTrConn, string barcode, int produceid, SUserInfo sUserInfo) { try { #region 查出工序条码类型 wangx 2017-3-13 string sqlString = "select BarCodeFlag from TP_PC_Procedure where ProcedureID=:ProcedureID"; OracleParameter[] paras2 = new OracleParameter[]{ new OracleParameter(":ProcedureID",produceid), }; DataSet ds = oracleTrConn.GetSqlResultToDs(sqlString, paras2); int BarCodeFlag = 0; string returnBarcode = string.Empty;//返回条码 if (ds != null && ds.Tables[0].Rows.Count > 0) { BarCodeFlag = Convert.ToInt32(ds.Tables[0].Rows[0]["BarCodeFlag"]); if (BarCodeFlag > 0) { //sqlString = @"select FUN_CMN_GetBarCode(:barcode,:procedureid,:accountid) From DUAL"; sqlString = @"select FUN_CMN_GetBarCode(:barcode,null,:accountid) From DUAL"; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), //new OracleParameter(":procedureid",OracleDbType.Int32, produceid,ParameterDirection.Input), new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input), }; ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); if (ds != null && ds.Tables[0].Rows.Count > 0) { returnBarcode = ds.Tables[0].Rows[0][0].ToString(); } return returnBarcode; } else { returnBarcode = barcode; } } #endregion return returnBarcode; } catch (Exception ex) { throw ex; } } /// /// 根据条码及工序判断是否漏扫 /// /// 产品条码 /// 校验工序ID /// 用户基本信息 /// DataSet public static int AddBarCodeMissing(IDBConnection oracleTrConn, string barcode, int produceid, SUserInfo sUserInfo) { try { #region 查询产成品 string sqlString = @"select TP_PM_InProduction.FlowProcedureID,NVL(TP_PM_InProduction.ReworkProcedureID,0) as ReworkProcedureID, TP_PM_InProduction.GoodsID,TP_PM_InProduction.GoodsCode,TP_PM_InProduction.GoodsName, TP_PC_Procedure.ProcedureCode,TP_PC_Procedure.ProcedureName,TP_MST_Goods.GoodsTypeID,TP_PM_InProduction.isrefire from TP_PM_InProduction left join TP_PC_Procedure on TP_PM_InProduction.FlowProcedureID=TP_PC_Procedure.ProcedureID left join TP_MST_Goods on TP_PM_InProduction.GoodsID=TP_MST_Goods.GoodsID where TP_PM_InProduction.BarCode =:barCode"; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":barCode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; DataSet ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); #endregion int AddBarCodeMissingID = 0;//新增漏扫表的ID if (ds != null && ds.Tables[0].Rows.Count > 0) //只有是在产的,才可以去进行漏扫 { #region 获取此条码为在产产品 int CompleteProcedureID = Convert.ToInt32(ds.Tables[0].Rows[0]["FlowProcedureID"]);//WMSYS.WM_CONCAT(to_char(pro.ProcedureName)),max(line.ProductionLineName) string CompleteProcedureCode = ds.Tables[0].Rows[0]["ProcedureCode"].ToString(); string CompleteProcedureName = ds.Tables[0].Rows[0]["ProcedureName"].ToString(); int GoodsID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsID"]); string GoodsCode = ds.Tables[0].Rows[0]["GoodsCode"].ToString(); string GoodsName = ds.Tables[0].Rows[0]["GoodsName"].ToString(); int GoodsTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsTypeID"]); int ReworkProcedureID = Convert.ToInt32(ds.Tables[0].Rows[0]["ReworkProcedureID"]);//返工工序 int isrefire = Convert.ToInt32(ds.Tables[0].Rows[0]["isrefire"]);//重烧标记 #endregion // 漏扫工序与检验工序不在一条路径上 modify by chenxy 2016-08-08 begin // 漏扫序号大的可到达工序与检验工序不在一条路径上时,要验证下一个可到达工序。 // 即与检验工序在一条路径上的漏扫序号最大可到达工序为漏扫工序。 #region 获取漏扫工序信息 if (ReworkProcedureID == 0) { sqlString = @" select TP_PC_Procedure.ProcedureID,TP_PC_Procedure.ProcedureCode,TP_PC_Procedure.ProcedureName,TP_PC_Procedure.NodeType from TP_PC_ProcedureGoods left join TP_PC_Procedure on TP_PC_ProcedureGoods.ProcedureID=TP_PC_Procedure.ProcedureID where TP_PC_ProcedureGoods.goodsid=( select Goodsid from TP_PM_GroutingDailyDetail where BarCode=:barCode) and TP_PC_ProcedureGoods.ProcedureID in( 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 =:procedureID and flow.FlowFlag = 2 and pro.valueflag = '1' -- 非必须工序,不记漏扫 and pro.MUSTFLAG = '1' ) " + //" and exists ( " + // "select 1 from " + // "(" + // "select procedureid, arriveprocedureid,ltrim(sys_connect_by_path(procedureid,'->')||'->'||arriveprocedureid) sybp from " + // "( " + // " select * from TP_PC_PROCEDUREFLOW where arriveprocedureid<>:missProcedureid and flowflag=2 " + // ") " + // //" start with procedureid=:missProcedureid" + // " start with procedureid=TP_PC_ProcedureGoods.ProcedureID" + // " connect by nocycle procedureid=prior arriveprocedureid" + // ") where arriveprocedureid=:judgeProcedureid " + // " ) " + //" order by ProcedureID"; " order by MissPriority DESC, displayno --ProcedureCode DESC"; paras = new OracleParameter[]{ new OracleParameter(":procedureID",OracleDbType.Int32,CompleteProcedureID,ParameterDirection.Input), new OracleParameter(":barCode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), //new OracleParameter(":missProcedureid",OracleDbType.Int32,missprocedureid,ParameterDirection.Input), //new OracleParameter(":judgeProcedureid",OracleDbType.Int32,produceid,ParameterDirection.Input), }; } else { sqlString = "select TP_PC_Procedure.ProcedureID,TP_PC_Procedure.ProcedureCode,TP_PC_Procedure.ProcedureName,TP_PC_Procedure.NodeType from TP_PC_Procedure where ProcedureID=:procedureID"; paras = new OracleParameter[]{ new OracleParameter(":procedureID",OracleDbType.Int32,ReworkProcedureID,ParameterDirection.Input), }; } ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { return AddBarCodeMissingID; } //int missprocedureid = Convert.ToInt32(ds.Tables[0].Rows[0]["ProcedureID"]); //string missprocedurecode = ds.Tables[0].Rows[0]["ProcedureCode"].ToString(); //string missprocedurename = ds.Tables[0].Rows[0]["ProcedureName"].ToString(); int missprocedureid = -1; string missprocedurecode = ""; string missprocedurename = ""; #endregion #region 增加判断校验工序必须是在漏扫工序的后面工序 //sqlString = "select * from " + // "(" + // "select procedureid, arriveprocedureid,ltrim(sys_connect_by_path(procedureid,'->')||'->'||arriveprocedureid) sybp from " + // "( " + // " select * from TP_PC_PROCEDUREFLOW where arriveprocedureid<>:missProcedureid and flowflag=2 " + // ")" + // " start with procedureid=:missProcedureid" + // " connect by nocycle procedureid=prior arriveprocedureid" + // ") where arriveprocedureid=:judgeProcedureid "; //paras = new OracleParameter[]{ // new OracleParameter(":missProcedureid",OracleDbType.Int32,missprocedureid,ParameterDirection.Input), // new OracleParameter(":judgeProcedureid",OracleDbType.Int32,produceid,ParameterDirection.Input), // }; //ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); //if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) //{ // return AddBarCodeMissingID; //} foreach (DataRow item in ds.Tables[0].Rows) { sqlString = "select * from " + "(" + "select procedureid, arriveprocedureid,ltrim(sys_connect_by_path(procedureid,'->')||'->'||arriveprocedureid) sybp from " + "( " + " select * from TP_PC_PROCEDUREFLOW where arriveprocedureid<>:missProcedureid and flowflag=2 " + ")" + " start with procedureid=:missProcedureid" + " connect by nocycle procedureid=prior arriveprocedureid" + ") where arriveprocedureid=:judgeProcedureid "; paras = new OracleParameter[]{ new OracleParameter(":missProcedureid",OracleDbType.Int32,Convert.ToInt32(item["ProcedureID"]),ParameterDirection.Input), new OracleParameter(":judgeProcedureid",OracleDbType.Int32,produceid,ParameterDirection.Input), }; ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { continue; } missprocedureid = Convert.ToInt32(item["ProcedureID"]); missprocedurecode = item["ProcedureCode"].ToString(); missprocedurename = item["ProcedureName"].ToString(); break; } if (missprocedureid == -1) { return AddBarCodeMissingID; } #endregion // 漏扫工序与检验工序不在一条路径上 modify by chenxy 2016-08-08 end //sqlString = "select TP_PC_Procedure.ProcedureID,TP_PC_Procedure.ProcedureCode,TP_PC_Procedure.ProcedureName,TP_PC_Procedure.NodeType from TP_PC_Procedure where ProcedureID=:procedureID"; //paras = new OracleParameter[]{ // new OracleParameter(":procedureID",OracleDbType.Int32,produceid,ParameterDirection.Input), // }; //ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); //int nodetype = Convert.ToInt32(ds.Tables[0].Rows[0]["NodeType"]);//获取当前工序的类型,为了判断如果成检设置重燃,未走重燃,直接包装,还有就是不记录以前工序的值 //if ((produceid > missprocedureid) || (ReworkProcedureID > 0 && nodetype == 3) || (isrefire == 6))//3 为结束节点,6为重烧 // 前面已经判断过 校验工序在漏扫工序(应该是当前工序吧)后 by chenxy 2020-03-29 begin //sqlString = "select 1 from TP_PM_ProductionDataIn where barcode=:barcode and ProcedureID=:ProcedureID and ValueFlag=1"; //paras = new OracleParameter[]{ // new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), // new OracleParameter(":ProcedureID",OracleDbType.Int32, produceid,ParameterDirection.Input), // }; //ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); //// if (produceid > missprocedureid) //if (ds != null && ds.Tables[0].Rows.Count == 0) // 未走过该工序 // 前面已经判断过 校验工序在漏扫工序(应该是当前工序吧)后 by chenxy 2020-03-29 end { #region 插入漏扫表,如果漏扫表里有相应的条码,不允许重复插入 sqlString = @"select missid from TP_PM_BarCodeMissing where barcode=:barcode and MissProcedureID=:MissProcedureID and ProcedureID=:ProcedureID"; paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), new OracleParameter(":MissProcedureID",OracleDbType.Int32, missprocedureid,ParameterDirection.Input), new OracleParameter(":ProcedureID",OracleDbType.Int32, produceid,ParameterDirection.Input), }; ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); if (ds != null && ds.Tables[0].Rows.Count == 0) // 没有此条码的工序,即插入 { int OrganizationID = 0; string OrganizationName = ""; string OrganizationCode = ""; string OrganizationFullName = ""; sqlString = @"select TP_MST_Organization.OrganizationID ,TP_MST_Organization.OrganizationName ,TP_MST_Organization.OrganizationCode ,TP_MST_Organization.OrganizationFullName from TP_PC_Procedure left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PC_Procedure.OrganizationID where TP_PC_Procedure.ProcedureID=:ProcedureID"; paras = new OracleParameter[]{ new OracleParameter(":ProcedureID",OracleDbType.Int32, missprocedureid,ParameterDirection.Input), }; ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); OrganizationID = Convert.ToInt32(ds.Tables[0].Rows[0]["OrganizationID"]); //组织机构ID OrganizationName = ds.Tables[0].Rows[0]["OrganizationName"].ToString(); //组织机构名称 OrganizationCode = ds.Tables[0].Rows[0]["OrganizationCode"].ToString(); //组织机构编码 OrganizationFullName = ds.Tables[0].Rows[0]["OrganizationFullName"].ToString(); //组织机构全称 // 获取校验工序信息 sqlString = @"select TP_PC_Procedure.ProcedureID ,TP_PC_Procedure.ProcedureCode ,TP_PC_Procedure.ProcedureName from TP_PC_Procedure where TP_PC_Procedure.ProcedureID=:ProcedureID"; paras = new OracleParameter[]{ new OracleParameter(":ProcedureID",OracleDbType.Int32, produceid,ParameterDirection.Input), }; ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); string ProcedureCode = ""; string ProcedureName = ""; if (ds != null && ds.Tables[0].Rows.Count > 0) // 没有此条码的工序,即插入 { ProcedureCode = ds.Tables[0].Rows[0]["ProcedureCode"].ToString(); ProcedureName = ds.Tables[0].Rows[0]["ProcedureName"].ToString(); } //漏扫表ID string sql = "select SEQ_PM_BarCodeMissing_MissID.nextval from dual"; AddBarCodeMissingID = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sql)); sqlString = @"insert into TP_PM_BarCodeMissing(MissID, BarCode, OrganizationID, OrganizationName, OrganizationCode, OrganizationFullName, CompleteProcedureID, CompleteProcedureCode, CompleteProcedureName, ProcedureID, ProcedureCode, ProcedureName, MissProcedureID, MissProcedureCode, MissProcedureName, GoodsID, GoodsCode, GoodsName, GoodsTypeID, CreateUserID, UpdateUserID, AccountID ) values ( :MissID, :BarCode, :OrganizationID, :OrganizationName, :OrganizationCode, :OrganizationFullName, :CompleteProcedureID, :CompleteProcedureCode, :CompleteProcedureName, :ProcedureID, :ProcedureCode, :ProcedureName, :MissProcedureID, :MissProcedureCode, :MissProcedureName, :GoodsID, :GoodsCode, :GoodsName, :GoodsTypeID, :CreateUserID, :UpdateUserID, :AccountID ) "; paras = new OracleParameter[]{ new OracleParameter(":MissID",OracleDbType.Int32, AddBarCodeMissingID,ParameterDirection.Input), new OracleParameter(":BarCode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), new OracleParameter(":OrganizationID",OracleDbType.Int32, OrganizationID,ParameterDirection.Input), new OracleParameter(":OrganizationName",OracleDbType.Varchar2, OrganizationName,ParameterDirection.Input), new OracleParameter(":OrganizationCode",OracleDbType.Varchar2, OrganizationCode,ParameterDirection.Input), new OracleParameter(":OrganizationFullName",OracleDbType.Varchar2, OrganizationFullName,ParameterDirection.Input), new OracleParameter(":CompleteProcedureID",OracleDbType.Int32, CompleteProcedureID,ParameterDirection.Input), new OracleParameter(":CompleteProcedureCode",OracleDbType.Varchar2, CompleteProcedureCode,ParameterDirection.Input), new OracleParameter(":CompleteProcedureName",OracleDbType.Varchar2, CompleteProcedureName,ParameterDirection.Input), new OracleParameter(":ProcedureID",OracleDbType.Int32, produceid,ParameterDirection.Input), new OracleParameter(":ProcedureCode",OracleDbType.Varchar2, ProcedureCode,ParameterDirection.Input), new OracleParameter(":ProcedureName",OracleDbType.Varchar2, ProcedureName,ParameterDirection.Input), new OracleParameter(":MissProcedureID",OracleDbType.Int32, missprocedureid,ParameterDirection.Input), new OracleParameter(":MissProcedureCode",OracleDbType.Varchar2,missprocedurecode ,ParameterDirection.Input), new OracleParameter(":MissProcedureName",OracleDbType.Varchar2, missprocedurename,ParameterDirection.Input), new OracleParameter(":GoodsID",OracleDbType.Int32, GoodsID,ParameterDirection.Input), new OracleParameter(":GoodsCode",OracleDbType.Varchar2,GoodsCode ,ParameterDirection.Input), new OracleParameter(":GoodsName",OracleDbType.Varchar2, GoodsName,ParameterDirection.Input), new OracleParameter(":GoodsTypeID",OracleDbType.Int32, GoodsTypeID,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), }; oracleTrConn.GetSqlResultToStr(sqlString, paras); } #endregion } } else //不在产 { #region 是否存在注浆产品 sqlString = @"select TP_PM_GroutingDailyDetail.BarCode,TP_PM_GroutingDailyDetail.GoodsID,TP_PM_GroutingDailyDetail.GoodsCode, TP_PM_GroutingDailyDetail.GoodsName,TP_MST_Goods.GoodsTypeID from TP_PM_GroutingDailyDetail left join TP_MST_Goods on TP_PM_GroutingDailyDetail.GoodsID=TP_MST_Goods.GoodsID where TP_PM_GroutingDailyDetail.BarCode=:BarCode"; paras = new OracleParameter[]{ new OracleParameter(":BarCode",OracleDbType.Varchar2,barcode,ParameterDirection.Input), }; ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); #endregion if (ds != null && ds.Tables[0].Rows.Count > 0) { // 此条码为在产产品 //int? CompleteProcedureID = null;//WMSYS.WM_CONCAT(to_char(pro.ProcedureName)),max(line.ProductionLineName) //string CompleteProcedureCode = ""; //string CompleteProcedureName = ""; int GoodsID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsID"]); string GoodsCode = ds.Tables[0].Rows[0]["GoodsCode"].ToString(); string GoodsName = ds.Tables[0].Rows[0]["GoodsName"].ToString(); int GoodsTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsTypeID"]); // #region 存在注浆产品,查看是否存在报损记录或者产成品记录 // sqlString = @"select BarCode from TP_PM_ScrapProduct where BarCode=:BarCode and ValueFlag=1 // union select BarCode from TP_PM_FinishedProduct where BarCode=:BarCode and ValueFlag=1"; // paras = new OracleParameter[]{ // new OracleParameter(":BarCode",OracleDbType.Varchar2,barcode,ParameterDirection.Input), // }; // ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); // #endregion // if (ds != null && ds.Tables[0].Rows.Count == 0) //即不在报损 ,也不在产成,说明未走任何工序 // { #region 查出校验工序的据在生产线,从而查出此生产上的漏扫开始工序节点 int ProductionLineID = 0; //查出校验工序生产线ID,用于区分多生产线的首个开始节点 sqlString = @"select ProductionLineID from TP_PC_Procedure where ProcedureID=:procedureID"; paras = new OracleParameter[]{ new OracleParameter(":procedureID",OracleDbType.Int32,produceid,ParameterDirection.Input), }; ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); if (ds != null && ds.Tables[0].Rows.Count > 0) // { ProductionLineID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionLineID"]); } sqlString = @" select TP_PC_Procedure.ProcedureID,TP_PC_Procedure.ProcedureCode,TP_PC_Procedure.ProcedureName,TP_PC_Procedure.NodeType from TP_PC_ProcedureGoods left join TP_PC_Procedure on TP_PC_ProcedureGoods.ProcedureID=TP_PC_Procedure.ProcedureID where TP_PC_ProcedureGoods.goodsid=( select Goodsid from TP_PM_GroutingDailyDetail where BarCode=:barCode) and TP_PC_ProcedureGoods.ProcedureID in( select ProcedureID from TP_PC_Procedure where ProductionLineID =:ProductionLineID and NodeType=1 and valueflag = '1') order by TP_PC_Procedure.misspriority desc, TP_PC_Procedure.displayno"; paras = new OracleParameter[]{ new OracleParameter(":ProductionLineID",OracleDbType.Int32,ProductionLineID,ParameterDirection.Input), new OracleParameter(":barCode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); #endregion if (ds != null && ds.Tables[0].Rows.Count > 0) //即不在报损 ,也不在产成,说明未走任何工序 { int missprocedureid = Convert.ToInt32(ds.Tables[0].Rows[0]["ProcedureID"]); string missprocedurecode = ds.Tables[0].Rows[0]["ProcedureCode"].ToString(); string missprocedurename = ds.Tables[0].Rows[0]["ProcedureName"].ToString(); #region 插入漏扫表,如果漏扫表里有相应的条码,不允许重复插入 sqlString = @"select 1 from TP_PM_BarCodeMissing where barcode=:barcode and MissProcedureID=:MissProcedureID and ProcedureID=:ProcedureID"; paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), new OracleParameter(":MissProcedureID",OracleDbType.Int32, missprocedureid,ParameterDirection.Input), new OracleParameter(":ProcedureID",OracleDbType.Int32,produceid,ParameterDirection.Input), }; ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); if (ds != null && ds.Tables[0].Rows.Count == 0) // 没有此条码的工序,即插入 { int OrganizationID = 0; string OrganizationName = ""; string OrganizationCode = ""; string OrganizationFullName = ""; sqlString = @"select TP_MST_Organization.OrganizationID ,TP_MST_Organization.OrganizationName ,TP_MST_Organization.OrganizationCode ,TP_MST_Organization.OrganizationFullName from TP_PC_Procedure left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PC_Procedure.OrganizationID where TP_PC_Procedure.ProcedureID=:ProcedureID"; paras = new OracleParameter[]{ new OracleParameter(":ProcedureID",OracleDbType.Int32, missprocedureid,ParameterDirection.Input), }; ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); OrganizationID = Convert.ToInt32(ds.Tables[0].Rows[0]["OrganizationID"]); //组织机构ID OrganizationName = ds.Tables[0].Rows[0]["OrganizationName"].ToString(); //组织机构名称 OrganizationCode = ds.Tables[0].Rows[0]["OrganizationCode"].ToString(); //组织机构编码 OrganizationFullName = ds.Tables[0].Rows[0]["OrganizationFullName"].ToString(); //组织机构全称 // 获取校验工序信息 sqlString = @"select TP_PC_Procedure.ProcedureID ,TP_PC_Procedure.ProcedureCode ,TP_PC_Procedure.ProcedureName from TP_PC_Procedure where TP_PC_Procedure.ProcedureID=:ProcedureID"; paras = new OracleParameter[]{ new OracleParameter(":ProcedureID",OracleDbType.Int32, produceid,ParameterDirection.Input), }; ds = oracleTrConn.GetSqlResultToDs(sqlString, paras); string ProcedureCode = ""; string ProcedureName = ""; if (ds != null && ds.Tables[0].Rows.Count > 0) // 没有此条码的工序,即插入 { ProcedureCode = ds.Tables[0].Rows[0]["ProcedureCode"].ToString(); ProcedureName = ds.Tables[0].Rows[0]["ProcedureName"].ToString(); } //漏扫表ID string sql = "select SEQ_PM_BarCodeMissing_MissID.nextval from dual"; AddBarCodeMissingID = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sql)); sqlString = @"insert into TP_PM_BarCodeMissing(MissID, BarCode, OrganizationID, OrganizationName, OrganizationCode, OrganizationFullName, ProcedureID, ProcedureCode, ProcedureName, MissProcedureID, MissProcedureCode, MissProcedureName, GoodsID, GoodsCode, GoodsName, GoodsTypeID, CreateUserID, UpdateUserID, AccountID ) values ( :MissID, :BarCode, :OrganizationID, :OrganizationName, :OrganizationCode, :OrganizationFullName, :ProcedureID, :ProcedureCode, :ProcedureName, :MissProcedureID, :MissProcedureCode, :MissProcedureName, :GoodsID, :GoodsCode, :GoodsName, :GoodsTypeID, :CreateUserID, :UpdateUserID, :AccountID ) "; paras = new OracleParameter[]{ new OracleParameter(":MissID",OracleDbType.Int32, AddBarCodeMissingID,ParameterDirection.Input), new OracleParameter(":BarCode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), new OracleParameter(":OrganizationID",OracleDbType.Int32, OrganizationID,ParameterDirection.Input), new OracleParameter(":OrganizationName",OracleDbType.Varchar2, OrganizationName,ParameterDirection.Input), new OracleParameter(":OrganizationCode",OracleDbType.Varchar2, OrganizationCode,ParameterDirection.Input), new OracleParameter(":OrganizationFullName",OracleDbType.Varchar2, OrganizationFullName,ParameterDirection.Input), //new OracleParameter(":CompleteProcedureID",OracleDbType.Int32, CompleteProcedureID,ParameterDirection.Input), //new OracleParameter(":CompleteProcedureCode",OracleDbType.Varchar2, CompleteProcedureCode,ParameterDirection.Input), //new OracleParameter(":CompleteProcedureName",OracleDbType.Varchar2, CompleteProcedureName,ParameterDirection.Input), new OracleParameter(":ProcedureID",OracleDbType.Int32, produceid,ParameterDirection.Input), new OracleParameter(":ProcedureCode",OracleDbType.Varchar2, ProcedureCode,ParameterDirection.Input), new OracleParameter(":ProcedureName",OracleDbType.Varchar2, ProcedureName,ParameterDirection.Input), new OracleParameter(":MissProcedureID",OracleDbType.Int32, missprocedureid,ParameterDirection.Input), new OracleParameter(":MissProcedureCode",OracleDbType.Varchar2,missprocedurecode ,ParameterDirection.Input), new OracleParameter(":MissProcedureName",OracleDbType.Varchar2, missprocedurename,ParameterDirection.Input), new OracleParameter(":GoodsID",OracleDbType.Int32, GoodsID,ParameterDirection.Input), new OracleParameter(":GoodsCode",OracleDbType.Varchar2,GoodsCode ,ParameterDirection.Input), new OracleParameter(":GoodsName",OracleDbType.Varchar2, GoodsName,ParameterDirection.Input), new OracleParameter(":GoodsTypeID",OracleDbType.Int32, GoodsTypeID,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), }; oracleTrConn.GetSqlResultToStr(sqlString, paras); } #endregion } //} } } return AddBarCodeMissingID; } catch (Exception ex) { throw ex; } } #endregion #region 查询 #region 获取生产工序实体 /// /// 获取生产工序实体 /// /// 工序ID /// 用户基本信息 /// ProcedureEntity实体类 public static ServiceResultEntity GetProcedureDataEntityByID(int procedureID, SUserInfo userInfo) { ServiceResultEntity sre = new ServiceResultEntity(); //ProcedureEntity procedureDataentity = new ProcedureEntity(); IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); 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) }; oracleConn.Open(); DataSet returnDs = oracleConn.ExecStoredProcedure(procsql, paras); sre.Data = returnDs; //if (returnDs != null && returnDs.Tables.Count > 0 && returnDs.Tables[0].Rows.Count > 0) //{ // DataRow row = returnDs.Tables[0].Rows[0]; // procedureDataentity = DataConvert.DataRowConvertToObject(row); // return procedureDataentity; //} //else //{ // return null; //} } catch (Exception ex) { throw ex; } finally { if (oracleConn.ConnState == ConnectionState.Open) { oracleConn.Close(); } } return sre; } #endregion #region 产品分级数据源 /// /// 产品分级数据源 /// /// 1适用半成品2检验 2适用成品检验 3入窑前检验 /// 用户基本信息 /// DataSet public static ServiceResultEntity GetGoodsLevel(int type, SUserInfo userInfo) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); string sqlString = ""; if (type == 1 || type == 3) { sqlString = "select GoodsLevelID as DefectFlagID,GoodsLevelName as DefectFlagName,GoodsLevelTypeID from TP_MST_GoodsLevel where IsSemiFinishedEx=1 and AccountID=:AccountID and ValueFlag=1 order by SFEDisplayNo"; } else if (type == 2) { sqlString = "select GoodsLevelID as DefectFlagID,GoodsLevelName as DefectFlagName,GoodsLevelTypeID from TP_MST_GoodsLevel where IsFinishedEx=1 and AccountID=:AccountID and ValueFlag=1 order by FEDisplayNo"; } OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":AccountID",userInfo.AccountID), }; sre.Data = con.GetSqlResultToDs(sqlString, paras); return sre; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } #endregion /// /// 获取重烧生产返工工序 /// /// 工序ID /// 产品条码 /// DataSet public static ServiceResultEntity GetReworkProcedureByProcedureID(int procedureID) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); string sqlString = @"select ProcedureID as ReworkProcedureID ,ProcedureName as ReworkProcedureName from TP_PC_Procedure p where ProductionLineID in( select ProductionLineID from TP_PC_Procedure where ProcedureID=:ProcedureID ) and p.valueflag='1' and IsSpecialRework IN('1','2') order by p.displayno "; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":ProcedureID",OracleDbType.Int32, procedureID,ParameterDirection.Input), }; sre.Data = con.GetSqlResultToDs(sqlString, paras); return sre; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 通过SettingCode获取系统参数管理的数据 /// /// 用户基本信息 /// DataSet /// /// 2016.10.10 王鑫 新建 /// public static ServiceResultEntity GetSystemSettingDataByCode(string settingcode, SUserInfo sUserInfo) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { //获取系统参数管理的数据 string sqlString = "Select SettingCode,SettingName,CategoryName,SettingValue,SettingDefaultValues,AccountID,Remarks,Tooltip,EditFlag,UpdateTime," + "UpdateUserID,OPTimeStamp from TP_MST_SystemSetting where AccountID = :AccountID and SettingCode=:SettingCode"; Oracle.ManagedDataAccess.Client.OracleParameter[] oracleParameter = new Oracle.ManagedDataAccess.Client.OracleParameter[] { new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID",sUserInfo.AccountID), new Oracle.ManagedDataAccess.Client.OracleParameter(":SettingCode",settingcode) }; oracleConn.Open(); sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter); oracleConn.Close(); return sre; } catch (Exception ex) { if (oracleConn.ConnState == ConnectionState.Open) { oracleConn.Close(); } throw ex; } } #region 校验生产工号 /// /// 检验此用户是否允许生产工序 /// /// 工序ID /// 工号ID /// CheckProcedureUserResult实体类 public static ServiceResultEntity CheckProcedureUser( string UserCode, SUserInfo sUserInfo) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { oracleConn.Open(); string sqlString = @"SELECT TP_MST_USER.ispublicbody,TP_MST_USER.USERID,TP_MST_USER.UserCode,TP_MST_USER.UserName , '' as ErrMsg FROM TP_MST_USER WHERE TP_MST_USER.UserCode=:UserCode and TP_MST_USER.ValueFlag = 1 and TP_MST_USER.IsWorker=1 and TP_MST_USER.AccountID=:accountID"; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":UserCode",OracleDbType.Varchar2,UserCode,ParameterDirection.Input), new OracleParameter(":accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input), }; DataSet resultDs = oracleConn.GetSqlResultToDs(sqlString, paras); //CheckProcedureUserResult checkProcedureUserResult = new CheckProcedureUserResult(); //if (resultDs != null && resultDs.Tables.Count > Constant.INT_IS_ZERO && resultDs.Tables[0].Rows.Count > Constant.INT_IS_ZERO) //{ // if (Convert.ToInt32(resultDs.Tables[0].Rows[0]["ProcedureUserid"]) == Constant.INT_IS_ZERO) // { // // 此工号不允许生产工序 // resultDs.Tables[0].Rows[0]["ErrMsg"] = string.Format(Messages.MSG_PM_W006, UserCode); // //checkProcedureUserResult.ErrMsg // // = string.Format(Messages.MSG_PM_W006, UserCode); // } // else // { // //checkProcedureUserResult.UserID = Convert.ToInt32(resultDs.Tables[0].Rows[0]["UserID"]); // //checkProcedureUserResult.UserCode = resultDs.Tables[0].Rows[0]["UserCode"].ToString(); // //checkProcedureUserResult.UserName = resultDs.Tables[0].Rows[0]["UserName"].ToString(); // //checkProcedureUserResult.Ispublicbody = resultDs.Tables[0].Rows[0]["Ispublicbody"].ToString() == "1" ? 1 : 0; // } //} //else //{ // resultDs.Tables[0].Rows[0]["ErrMsg"] = string.Format(Messages.MSG_CMN_W019, UserCode, "生产工号"); // //checkProcedureUserResult.ErrMsg // // = string.Format(Messages.MSG_CMN_W019, UserCode, "生产工号"); //} #region 查询该工号下是否有试用或者转正的生产员工 if (string.IsNullOrEmpty(resultDs.Tables[0].Rows[0]["ErrMsg"] + "")) { sqlString = @" select count(*) from tp_hr_staff where staffid in(select staffid from tp_mst_userstaff where userid=:userID) and valueflag=1 and (staffstatus=1 or staffstatus=2)"; paras = new OracleParameter[]{ new OracleParameter(":userID",OracleDbType.Int32,Convert.ToInt32(resultDs.Tables[0].Rows[0]["UserID"]),ParameterDirection.Input), }; string count = oracleConn.GetSqlResultToStr(sqlString, paras); if (int.Parse(count) == Constant.INT_IS_ZERO) { resultDs.Tables[0].Rows[0]["ErrMsg"] = string.Format(Messages.MSG_PM_W005, UserCode); } } sre.Data = resultDs; #endregion return sre; } catch (Exception ex) { throw ex; } finally { if (oracleConn.ConnState == ConnectionState.Open) { oracleConn.Close(); } } } #endregion /// /// 使用存储过程PRO_PM_GetProductionData获取生产工序计件数据 /// /// 生产数据实体类 /// 用户基本信息 /// DataTable public static ServiceResultEntity GetProductionDataPDA(int procedureID, string barCode, SUserInfo user) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); string procsql = "";//PRO_PM_GetProductionDataPDA //xuwei modify 2019-12-13 修正读取当前工序 是编辑还是插入 procsql = @"SELECT TP_PM_ProductionDataIn.ProductionDataID FROM TP_PM_ProductionDataIn where valueflag=1 and 1=1 and ProcedureID=" + procedureID + " and barcode='" + barCode + "' order by TP_PM_ProductionDataIn.ProductionDataid desc"; try { oracleConn.Open(); sre.Data = oracleConn.GetSqlResultToDs(procsql); return sre; } catch (Exception ex) { throw ex; } finally { if (oracleConn.ConnState == ConnectionState.Open) { oracleConn.Close(); } } } /// /// 获取编辑的生产数据ID与列表所选生产数据ID做比较 /// /// 产品条码 /// int public static ServiceResultEntity GetCompleteProductionDataID(string barcode) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); string sqlString = @"select ProductionDataID from TP_PM_InProduction where TP_PM_InProduction.BarCode=:BarCode union select ProductionDataID from Tp_Pm_Inproductiontrash where Tp_Pm_Inproductiontrash.BarCode=:BarCode "; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":BarCode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; sre.Data = con.GetSqlResultToDs(sqlString, paras); return sre; //if (ds != null && ds.Tables[0].Rows.Count > 0) //{ // return Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionDataID"]); //} //else //{ // return 0; //} } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 成检时获取此条码是否报损 /// 产品条码 /// /// int public static ServiceResultEntity CheckScrapProduct(string barcode) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); string sqlString = @"select auditstatus from tp_pm_scrapproduct where auditstatus in(0,1) and valueflag=1 and goodsleveltypeid=8 and barcode=:barcode and recyclingflag=0"; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; sre.Data = con.GetSqlResultToDs(sqlString, paras); return sre; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 根据所选生产数据ID,显示成检数据信息 /// /// 生产数据ID /// DataSet public static ServiceResultEntity GetProductionDataByID(int productionDataID) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); DataSet dsReturn = new DataSet(); string sqlString = @"select TP_PM_ProductionDataIn.Barcode as BarCode, TP_PM_ProductionDataIn.Goodsid as GoodsID, TP_PM_ProductionDataIn.Goodscode as GoodsCode, TP_PM_ProductionDataIn.Goodsname as GoodsName, TP_PM_ProductionDataIn.GoodsLevelID as DefectFlagID, TP_PM_ProductionDataIn.Reworkprocedureid as ReworkProcedureID, TP_PM_ProductionDataIn.Remarks as Remarks, TP_PM_ProductionDataIn.Userid as UserID, TP_PM_ProductionDataIn.UserCode as UserCode, TP_PM_ProductionDataIn.UserName as UserName, TP_PM_ProductionDataIn.Goodsleveltypeid as GoodsLevelTypeID, TP_PM_ProductionDataIn.SpecialRepairflag, TP_PM_ProductionDataIn.IsReFire, TP_PM_ProductionDataIn.KilnCode, TP_PM_ProductionDataIn.KilnCarCode, TP_PM_ProductionDataIn.GroutingUserCode, TP_PM_ProductionDataIn.GroutingMouldCode as MouldCode, TP_PM_ProductionDataIn.GroutingNum, TP_PM_ProductionDataIn.GroutingDate, TP_PM_ProductionDataIn.IsPublicBody, TP_MST_Logo.logoid, TP_MST_Logo.logocode, TP_MST_Logo.logoname, TP_PM_ProductionDataIn.CreateTime, TP_PM_ProductionDataIn.CheckTime, dd.DICTIONARYVALUE as GLAZEName, gdd.LEAKFLAG1, gdd.LEAKFLAG2, gdd.LEAKFLAG3, decode(TP_PM_ProductionDataIn.SpecialRepairFlag,'1','是','0','否') as SpecialRepairflagName, decode(TP_PM_ProductionDataIn.IsReFire,'6','是','0','否') as IsReFireName, decode(gdd.LEAKFLAG1,'1','合格','0','不合格','未检测') as LEAKFLAG1Name, decode(gdd.LEAKFLAG2,'1','合格','0','不合格','未检测') as LEAKFLAG2Name, decode(gdd.LEAKFLAG3,'1','合格','0','不合格','未检测') as LEAKFLAG3Name from TP_PM_ProductionDataIn INNER JOIN TP_PM_GROUTINGDAILYDETAIL gdd on gdd.BARCODE = TP_PM_ProductionDataIn.BARCODE left join TP_MST_DATADICTIONARY dd on dd.DICTIONARYID = gdd.GLAZETYPEID left join TP_MST_Logo on gdd.logoid=TP_MST_Logo.logoid where TP_PM_ProductionDataIn.Productiondataid=:ProductionDataID "; string sqlString2 = @" select TP_PM_Defect.ProductionDefectID as ProductionDefectID, TP_PM_Defect.Barcode as BarCode, TP_PM_Defect.DefectID as DefectID, TP_PM_Defect.Defectname as DefectName, TP_PM_Defect.Defectcode as DefectCode, TP_PM_Defect.Defectpositionid as DefectPositionID, TP_PM_Defect.Defectpositionname as DefectPositionName, TP_PM_Defect.Defectpositioncode as DefectPositionCode, TP_PM_Defect.Defectprocedureid as DefectProcedureID, TP_PM_Defect.Defectprocedurename as DefectProcedureName, TP_PM_Defect.Defectprocedurecode as DefectProcedureCode, TP_PM_Defect.Defectuserid as DefectUserID, TP_PM_Defect.Defectusername as DefectUserName, TP_PM_Defect.Defectusercode as DefectUserCode, TP_PM_Defect.DefectJobs as Jobs, nvl(TP_PM_Defect.MissedUserID,-1) as MissedUserID, TP_PM_Defect.MissedUserCode, TP_PM_Defect.MissedUserName, TP_MST_Jobs.Jobsname as JobsText, TP_PM_Defect.Remarks as DefectRemarks, TP_PM_Defect.Productiondataid as ProductionDataID, nvl(TP_PM_Defect.DefectProductionDataID,0) as DefectProductionDataID, TP_PM_Defect.Defectfine as DefectFineID, TP_MST_DefectFine.DefectFineCode as DefectFineValue, TP_PM_Defect.SpecialDefect, TP_PM_Defect.DefectDeductionNum, TP_PM_Defect.CheckTime from TP_PM_Defect left join TP_MST_Jobs on TP_PM_Defect.Defectjobs=TP_MST_Jobs.JobsID left join TP_MST_DefectFine on TP_PM_Defect.Defectfine= TP_MST_DefectFine.DefectFineid where TP_PM_Defect.Productiondataid =:ProductionDataID"; string sqlString3 = @"select TP_PM_DefectResponsible.ProductionDefectID as ProductionDefectID, TP_PM_DefectResponsible.Staffid as StaffID, TP_HR_Staff.Staffcode as StaffCode, TP_HR_Staff.Staffname as StaffName, TP_PM_DefectResponsible.Staffstatus as StaffStatus, TP_PM_DefectResponsible.UJobsID, TP_PM_DefectResponsible.SJobsID from TP_PM_DefectResponsible left join TP_HR_Staff on TP_PM_DefectResponsible.StaffID=TP_HR_Staff.Staffid where TP_PM_DefectResponsible.Productiondefectid in ( select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID )"; string sqlString4 = @" select TP_PM_DefectImage.ProductionDefectID, TP_PM_DefectImage.Thumbnailpath, TP_PM_DefectImage.Imagepath from TP_PM_DefectImage where TP_PM_DefectImage.Productiondefectid in ( select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID )"; string sqlString5 = @"select TP_PM_DefectMissedResponsible.ProductionDefectID as ProductionDefectID, TP_PM_DefectMissedResponsible.Staffid as StaffID, TP_HR_Staff.Staffcode as StaffCode, TP_HR_Staff.Staffname as StaffName, TP_PM_DefectMissedResponsible.Staffstatus as StaffStatus, TP_PM_DefectMissedResponsible.UJobsID, TP_PM_DefectMissedResponsible.SJobsID from TP_PM_DefectMissedResponsible left join TP_HR_Staff on TP_PM_DefectMissedResponsible.StaffID=TP_HR_Staff.Staffid where TP_PM_DefectMissedResponsible.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), }; DataSet ds = con.GetSqlResultToDs(sqlString, paras); ds.Tables[0].TableName = "TP_PM_ProductionData"; DataSet ds2 = con.GetSqlResultToDs(sqlString2, paras); ds2.Tables[0].TableName = "TP_PM_Defect"; DataSet ds3 = con.GetSqlResultToDs(sqlString3, paras); ds3.Tables[0].TableName = "TP_PM_DefectResponsible"; DataSet ds4 = con.GetSqlResultToDs(sqlString4, paras); ds4.Tables[0].TableName = "TP_PM_DefectImage"; DataSet ds5 = con.GetSqlResultToDs(sqlString5, paras); ds5.Tables[0].TableName = "TP_PM_DefectMissedResponsible"; dsReturn.Tables.Add(ds.Tables[0].Copy()); dsReturn.Tables.Add(ds2.Tables[0].Copy()); dsReturn.Tables.Add(ds3.Tables[0].Copy()); dsReturn.Tables.Add(ds4.Tables[0].Copy()); dsReturn.Tables.Add(ds5.Tables[0].Copy()); sre.Data = dsReturn; return sre; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 获取标识 /// /// 产品条码ram> /// int public static ServiceResultEntity GetRecyclingflagByBarcode(string barcode, SUserInfo sUserInfo) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); string sqlString = "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"; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":BarCode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; sre.Data = con.GetSqlResultToDs(sqlString, paras); return sre; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 获取在产产品的信息标识列表 /// /// 产品条码 /// int public static ServiceResultEntity GetInProductionDataList(string barcode) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); string sqlString = @"select BarCode, FlowProcedureID, FlowProcedureTime, ProcedureID, ProcedureTime, ProductionDataID, IsReFire, SpecialRepairFlag from TP_PM_InProduction where TP_PM_InProduction.BarCode=:BarCode "; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":BarCode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; sre.Data = con.GetSqlResultToDs(sqlString, paras); return sre; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 检验条码(非首节点) /// /// 工序ID /// 产品条码 /// DataSet public static ServiceResultEntity CheckBarcode(int procedureID, string barcode, SUserInfo sUserInfo, bool isInn = false) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { oracleConn.Open(); // 2019-1016 if (!isInn) { //xuwei fix 2019-09-26 使用通用方法判定 //if (PMModuleLogicDAL.IsNodeBegin(oracleConn, barcode) == 1) //{ // return CheckBarcodeDeliverMud(procedureID, barcode, sUserInfo, true); //}fAddCheckBarcode string sql1 = "select NodeType from tp_pc_procedure where procedureid=:procedureid"; string NodeType = oracleConn.GetSqlResultToObj(sql1, new OracleParameter[] { new OracleParameter(":procedureid", procedureID) }) + ""; // 89[3#一检半检] 特殊处理 if (NodeType == "1" || procedureID == 89) { int isNodeBegin = IsNodeBegin(oracleConn, barcode); if (isNodeBegin == 1) { sre.Data = CheckBarcodeDeliverMud(procedureID, barcode, sUserInfo, true); return sre; } } } DataTable dtBarCode = CreateBarCodeResultTable(); DataSet returnDs = new DataSet(); DataRow dr = dtBarCode.NewRow(); string sqlString = string.Empty; string sqlString1 = string.Empty; string sqlString2 = string.Empty; DataSet ds = null; #region 查出工序条码类型 wangx 2017-3-13 string sqlBarcode = GetConvertBarCode(oracleConn, barcode, procedureID, sUserInfo); if (sqlBarcode == string.Empty) { dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "无效条码"; dr[Constant.BarCodeResultTableColumns.out_missFlag.ToString()] = 0; dtBarCode.Rows.Add(dr); returnDs.Tables.Add(dtBarCode); sre.Data = returnDs; return sre; } else { dr[Constant.BarCodeResultTableColumns.out_barcode.ToString()] = sqlBarcode; barcode = sqlBarcode; } #endregion OracleParameter[] paras = new OracleParameter[]{ new OracleParameter("in_procedureid",OracleDbType.Int32,procedureID,ParameterDirection.Input), new OracleParameter("in_barcode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input), new OracleParameter("out_errMsg",OracleDbType.NVarchar2,2000,null,ParameterDirection.Output), new OracleParameter("out_goodsID",OracleDbType.Int32,ParameterDirection.Output), new OracleParameter("out_goodsCode",OracleDbType.NVarchar2,50,null,ParameterDirection.Output), new OracleParameter("out_goodsName",OracleDbType.NVarchar2,50,null,ParameterDirection.Output), new OracleParameter("out_groutingUserCode",OracleDbType.NVarchar2,50,null,ParameterDirection.Output), new OracleParameter("out_errMsg_Status",OracleDbType.Varchar2,50,"",ParameterDirection.Output), }; oracleConn.ExecStoredProcedure("PRO_PM_CheckBarcode", paras); //dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] // = paras[2].Value.ToString() == "null" ? "" : paras[2].Value.ToString().Replace("\\n\\r", "\n\r"); //if (!string.IsNullOrEmpty(paras[2].Value.ToString() == "null" ? "" : paras[2].Value.ToString().Replace("\\n\\r", "\n\r"))) //{ // AddBarCodeMissing(oracleConn, barcode, procedureID, sUserInfo); //} //int missFlag = 0; //if (paras[7].Value != null && paras[7].Value.ToString() == "1") //{ // missFlag = AddBarCodeMissing(oracleConn, barcode, procedureID, sUserInfo); //} dr[Constant.BarCodeResultTableColumns.out_goodsID.ToString()] = paras[3].Value.ToString() == "null" ? 0 : paras[3].Value; dr[Constant.BarCodeResultTableColumns.out_goodsCode.ToString()] = paras[4].Value.ToString() == "null" ? "" : paras[4].Value; dr[Constant.BarCodeResultTableColumns.out_goodsName.ToString()] = paras[5].Value.ToString() == "null" ? "" : paras[5].Value; dr[Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()] = paras[6].Value.ToString() == "null" ? 0 : paras[6].Value; dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = ""; dr[Constant.BarCodeResultTableColumns.out_missFlag.ToString()] = 0; //dr[Constant.BarCodeResultTableColumns.out_missFlag.ToString()] = missFlag; //判断所在工序是否是表中成品检验工序ID不为空的 20221103 by qinq sqlString = "SELECT t.procedureid\n" + " ,t.procedurename\n" + " FROM tp_pc_procedure t\n" + " WHERE t.valueflag = '1'\n" + " AND t.AccountID = :accountid\n" + " AND t.finishedcheckprocedureid IS NOT NULL\n" + " AND t.procedureid = :procedureid\n"; paras = new OracleParameter[]{ new OracleParameter(":accountid",sUserInfo.AccountID), new OracleParameter(":procedureid",procedureID), }; DataSet procedureData = oracleConn.GetSqlResultToDs(sqlString, paras); //查询为空,该工序不满足条件 if (procedureData == null || procedureData.Tables[0].Rows.Count == 0) { dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "当前工序不能进行成品检验"; dtBarCode.Rows.Add(dr); dtBarCode.TableName = "InproductionTable"; returnDs.Tables.Add(dtBarCode); } else { sqlString = @"select tp_pm_inproduction.GoodsName, tp_pm_inproduction.GroutingUserID, tp_pm_inproduction.GroutingUserCode, tp_pm_inproduction.GroutingNum, tp_pm_inproduction.GroutingMouldCode as MouldCode, tp_pm_inproduction.ispublicbody, tp_pm_inproduction.Groutingdate, tp_pm_inproduction.SpecialRepairFlag, tp_pm_inproduction.logoid, g.goodsid,g.goodscode,g.PlateLimitNum,g.DeliverLimitCycle, --nvl(g.MaterialCode,g.GoodsCode) as GOODSMODELforCheck, -- 用物料编码验证产品型号是否一致 nvl(gdd.MaterialCode, nvl(g.MaterialCode,g.GoodsCode)) ||'#'|| to_char(g.GOODS_LINE_TYPE) as GOODSMODELforCheck, -- 用物料编码验证产品型号是否一致 --gt.gt.goodstypecode,gt.goodstypename,a.workcode, tp_mst_logo.logocode, u.username as GroutingUserName, tp_mst_logo.logoname, p.procedurename, p.procedureID, p.finishedcheckprocedureid from tp_pm_inproduction left join TP_PM_GroutingDailyDetail gdd on gdd.GroutingDailyDetailID = tp_pm_inproduction.GroutingDailyDetailID left join tp_mst_logo on tp_pm_inproduction.logoid=tp_mst_logo.logoid inner join tp_mst_user u on u.userid = gdd.userid LEFT JOIN TP_MST_GOODS G ON G.GoodsID = tp_pm_inproduction.goodsid left join tp_pc_procedure p on p.procedureid = tp_pm_inproduction.procedureid left join tp_pc_procedure fp on fp.finishedcheckprocedureid = p.procedureid where tp_pm_inproduction.BarCode=:barcode"; sqlString1 = @"SELECT t.RELATIONID ,t.BARCODE ,t.MATNR ,t.IDNRK ,t.MEINS ,t.MENGE ,t.IDNRKNAME as DetailName ,t.IDNRKONLYCODE ,t.CHARG ,t.LGORT ,0 as FrmLossCheck ,0 as RecoverCheck ,0 as NewCheck ,'' as NEWIDNRKONLYCODE ,'' as SCRAPREASON ,0 as DICTIONARYID FROM TP_PM_BARCODEIDNRKREL t where t.BARCODE = :barcode and t.ValueFlag = '1'"; paras = new OracleParameter[]{ new OracleParameter(":barcode",barcode),}; sqlString2 = @"SELECT pi.* FROM TP_PM_ProductionDataIn pi where pi.Barcode= :barcode and pi.MODELTYPE IN (-1, -4, -5) and pi.ValueFlag = '1' order by pi.CREATETIME desc"; ds = oracleConn.GetSqlResultToDs(sqlString, paras); DataSet detailTable = oracleConn.GetSqlResultToDs(sqlString1, paras); DataSet dataTable = oracleConn.GetSqlResultToDs(sqlString2, paras); DataSet defectSet = new DataSet(); if (ds != null && ds.Tables[0].Rows.Count > 0) { dr["GOODSMODELforCheck"] = ds.Tables[0].Rows[0]["GOODSMODELforCheck"].ToString(); //// hegii 三水 特殊处理 大件高压可以和普通合并装板,小件高压不能和普通合并装板 //if (ds.Tables[0].Rows[0]["workcode"].ToString() == "5020" && // ds.Tables[0].Rows[0]["goodstypename"].ToString() == "小件") //{ // dr["GOODSMODELforCheck"] = ds.Tables[0].Rows[0]["goodscode"].ToString(); //} dr["PlateLimitNum"] = ds.Tables[0].Rows[0]["PlateLimitNum"]; dr["ProcedureName"] = ds.Tables[0].Rows[0]["procedurename"]; dr["FinishedCheckProcedureid"] = ds.Tables[0].Rows[0]["finishedcheckprocedureid"]; dr["procedureID"] = ds.Tables[0].Rows[0]["procedureID"]; if (dataTable != null && dataTable.Tables.Count > 0 && dataTable.Tables[0].Rows.Count > 0) { dr["DefectFlagID"] = Convert.ToInt32(dataTable.Tables[0].Rows[0]["goodsleveltypeid"]); } dr[Constant.BarCodeResultTableColumns.out_goodsID.ToString()] = ds.Tables[0].Rows[0]["GoodsID"].ToString(); dr[Constant.BarCodeResultTableColumns.out_goodsCode.ToString()] = ds.Tables[0].Rows[0]["GoodsCode"].ToString(); dr[Constant.BarCodeResultTableColumns.out_goodsName.ToString()] = ds.Tables[0].Rows[0]["GoodsName"].ToString(); dr[Constant.BarCodeResultTableColumns.out_missFlag.ToString()] = 0; dr[Constant.BarCodeResultTableColumns.out_groutingUserName.ToString()] = ds.Tables[0].Rows[0]["GroutingUserName"].ToString(); dr[Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()] = ds.Tables[0].Rows[0]["GroutingUserCode"].ToString(); dr[Constant.BarCodeResultTableColumns.out_groutingUserID.ToString()] = ds.Tables[0].Rows[0]["GroutingUserID"].ToString(); dr[Constant.BarCodeResultTableColumns.out_groutingNum.ToString()] = ds.Tables[0].Rows[0]["GroutingNum"].ToString(); dr[Constant.BarCodeResultTableColumns.out_mouldCode.ToString()] = ds.Tables[0].Rows[0]["MouldCode"].ToString(); dr[Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()] = ds.Tables[0].Rows[0]["ispublicbody"].ToString(); dr[Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()] = "0"; dr[Constant.BarCodeResultTableColumns.out_groutingdate.ToString()] = ds.Tables[0].Rows[0]["Groutingdate"].ToString(); dr[Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()] = ds.Tables[0].Rows[0]["SpecialRepairFlag"].ToString(); dr[Constant.BarCodeResultTableColumns.out_isReFire.ToString()] = "0"; dr[Constant.BarCodeResultTableColumns.out_logoID.ToString()] = ds.Tables[0].Rows[0]["logoid"].ToString(); dr[Constant.BarCodeResultTableColumns.out_logoCode.ToString()] = ds.Tables[0].Rows[0]["logocode"].ToString(); dr[Constant.BarCodeResultTableColumns.out_logoName.ToString()] = ds.Tables[0].Rows[0]["logoname"].ToString(); dr[Constant.BarCodeResultTableColumns.out_deliverLimitCycle.ToString()] = ds.Tables[0].Rows[0]["DeliverLimitCycle"].ToString(); } dtBarCode.Rows.Add(dr); dtBarCode.TableName = "InproductionTable"; returnDs.Tables.Add(dtBarCode); detailTable.Tables[0].TableName = "DetailTable"; returnDs.Tables.Add(detailTable.Tables[0].Copy()); //获取上一次成品检验的缺陷 if (dataTable != null && dataTable.Tables.Count > 0 && dataTable.Tables[0].Rows.Count > 0) { sqlString2 = @"select TP_PM_Defect.DefectID ,replace( concat(TP_PM_Defect.DefectCode||'->',TP_PM_Defect.DefectName) , concat(TP_PM_Defect.DefectCode||'->',TP_PM_Defect.DefectCode||'->'),TP_PM_Defect.DefectCode||'->' ) as DefectName, TP_PM_Defect.DefectCode, TP_PM_Defect.DefectPositionID, replace( concat(TP_PM_Defect.DefectPositionCode||'->',TP_PM_Defect.DefectPositionName) , concat(TP_PM_Defect.DefectPositionCode||'->',TP_PM_Defect.DefectPositionCode||'->'),TP_PM_Defect.DefectPositionCode||'->' ) as DefectPositionName, TP_PM_Defect.DefectPositionCode, TP_PM_Defect.DefectProcedureID, TP_PM_Defect.DefectProcedureCode, TP_PM_Defect.DefectProcedureName,TP_PM_Defect.DefectUserID ,TP_PM_Defect.DefectUserCode,TP_PM_Defect.DefectUserName, TP_PM_Defect.DefectProductionDataID, TP_PM_Defect.Remarks AS DefectRemarks , TP_MST_Jobs.JobsID AS Jobs, TP_MST_Jobs.JobsName AS JobsText, TP_MST_DefectFine.DefectFineID, TP_MST_DefectFine.DefectFineCode AS DefectFineValue, TP_PM_Defect.MissedUserID, TP_PM_Defect.MissedUserCode, TP_PM_Defect.MissedUserName, TP_PM_Defect.DefectDeductionNum, TP_PM_Defect.SpecialDefect, TP_PM_Defect.CheckTime, (SELECT listagg(to_char(s.staffname), ',') within GROUP(ORDER BY s.staffid) FROM tp_pm_defectresponsible dp INNER JOIN tp_hr_staff s ON s.staffid = dp.staffid where dp.productiondefectid = TP_PM_Defect.PRODUCTIONDEFECTID) DefectStaffNames , ROWNUM-1 as TempCount from TP_PM_Defect left join TP_MST_Jobs on TP_PM_Defect.DefectJobs=TP_MST_Jobs.JobsID left join TP_MST_DefectFine on TP_PM_Defect.DefectFine=TP_MST_DefectFine.DefectFineID where TP_PM_Defect.ProductionDataID = :ProductionDataID"; OracleParameter[] paras1 = new OracleParameter[]{ new OracleParameter(":ProductionDataID",Convert.ToInt32(dataTable.Tables[0].Rows[0]["ProductionDataID"])), }; defectSet = oracleConn.GetSqlResultToDs(sqlString2, paras1); if (defectSet != null && defectSet.Tables.Count > 0 && defectSet.Tables[0].Rows.Count > 0) { defectSet.Tables[0].TableName = "DefectTable"; returnDs.Tables.Add(defectSet.Tables[0].Copy()); } } } //if (paras[7].Value.ToString() == "null") //只有正确的条码,读注浆信息 //{ //} sre.Data = returnDs; return sre; } catch (Exception ex) { throw ex; } finally { if (oracleConn.ConnState == ConnectionState.Open) { oracleConn.Close(); } } } /// /// 交坯验证条码(首节点) /// /// 工序ID /// 产品条码 /// DataSet public static DataSet CheckBarcodeDeliverMud(int procedureID, string barcode, SUserInfo sUserInfo, bool isInn = false) { IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { oracleConn.IgnoreCase = false; oracleConn.Open(); // 2019-1016 if (!isInn) { //xuwei fix 2019-09-26 使用通用方法判定 //if (PMModuleLogicDAL.IsNodeBegin(oracleConn, barcode) == 0) //{ // return CheckBarcode(procedureID, barcode, sUserInfo, true); //} string sql1 = "select NodeType from tp_pc_procedure where procedureid=:procedureid"; string NodeType = oracleConn.GetSqlResultToObj(sql1, new OracleParameter[] { new OracleParameter(":procedureid", procedureID) }) + ""; if (NodeType == "1") { int isNodeBegin = IsNodeBegin(oracleConn, barcode); if (isNodeBegin == 0) { ServiceResultEntity sre = CheckBarcode(procedureID, barcode, sUserInfo, true); return sre.Data; } } else { ServiceResultEntity sre = CheckBarcode(procedureID, barcode, sUserInfo, true); return sre.Data; } } string sql = "select barcodestatus,GroutingDailyDetailid from TP_PM_USEDBARCODE where BarCode='" + barcode + "'"; sql = "select barcodestatus,GroutingDailyDetailid from TP_PM_USEDBARCODE where BarCode=:barcode"; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter("barcode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input), }; DataSet ds = oracleConn.GetSqlResultToDs(sql, paras); DataTable dtBarCode = CreateBarCodeResultTable(); DataSet returnDs = new DataSet(); DataRow dr = dtBarCode.NewRow(); dr[Constant.BarCodeResultTableColumns.out_barcode.ToString()] = barcode; if (ds != null && ds.Tables[0].Rows.Count == 0) { dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "无效条码[" + barcode + "]"; } else { //不等于空的时候 if (ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "-1") { sql = "select max(newbarcode) from TP_PM_BarCodeRecord where BarCode='" + barcode + "'"; string newbarcode = oracleConn.GetSqlResultToStr(sql); dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "条码已被替换,新条码为" + newbarcode; } else if (ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "2") { dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "产品已成型报损"; } else if (ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "3" || ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "4") { //dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "产品已交坯"; dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "产品已在产"; } else if (ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "1") { dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = ""; string sqlString = @"select tp_pm_GroutingDailyDetail.GoodsID, tp_pm_GroutingDailyDetail.GoodsCode, tp_pm_GroutingDailyDetail.GoodsName, tp_pm_GroutingDailyDetail.UserID as GroutingUserID, tp_pm_GroutingDailyDetail.UserCode as GroutingUserCode, tp_mst_user.username as GroutingUserName, tp_pm_GroutingDailyDetail.groutingcount as GroutingNum, tp_pm_GroutingDailyDetail.GroutingMouldCode as MouldCode, tp_pm_GroutingDailyDetail.ispublicbody, tp_pm_GroutingDailyDetail.Groutingdate, tp_pm_GroutingDailyDetail.SpecialRepairFlag, tp_mst_logo.logoid, tp_mst_logo.logocode, tp_mst_logo.logoname, TP_MST_Goods.DeliverLimitCycle from tp_pm_GroutingDailyDetail left join tp_mst_logo on tp_pm_GroutingDailyDetail.logoid=tp_mst_logo.logoid left join tp_mst_user on tp_pm_GroutingDailyDetail.userid=tp_mst_user.userid left join TP_MST_Goods on tp_pm_GroutingDailyDetail.GoodsID=TP_MST_Goods.GoodsID where tp_pm_GroutingDailyDetail.groutingdailydetailid=" + ds.Tables[0].Rows[0]["GroutingDailyDetailid"].ToString(); //paras = new OracleParameter[]{ // new OracleParameter(":groutingdailydetailid",ds.Tables[0].Rows[0]["GroutingDailyDetailid"].ToString()), // }; ds = oracleConn.GetSqlResultToDs(sqlString, null); if (ds != null && ds.Tables[0].Rows.Count > 0) { 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 = oracleConn.GetSqlResultToDs(sqlExistGoods, paras); if (dsGoods.Tables[0].Rows[0][0].ToString() != "1") { dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = @"条码[" + barcode + "]不可以经过该工序\n\r原因:条码对应的产品编码[" + ds.Tables[0].Rows[0]["GoodsCode"].ToString() + "]没有在该工序中配置"; } else { dr[Constant.BarCodeResultTableColumns.out_goodsID.ToString()] = ds.Tables[0].Rows[0]["GoodsID"].ToString(); dr[Constant.BarCodeResultTableColumns.out_goodsCode.ToString()] = ds.Tables[0].Rows[0]["GoodsCode"].ToString(); dr[Constant.BarCodeResultTableColumns.out_goodsName.ToString()] = ds.Tables[0].Rows[0]["GoodsName"].ToString(); dr[Constant.BarCodeResultTableColumns.out_missFlag.ToString()] = 0; dr[Constant.BarCodeResultTableColumns.out_groutingUserName.ToString()] = ds.Tables[0].Rows[0]["GroutingUserName"].ToString(); dr[Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()] = ds.Tables[0].Rows[0]["GroutingUserCode"].ToString(); dr[Constant.BarCodeResultTableColumns.out_groutingUserID.ToString()] = ds.Tables[0].Rows[0]["GroutingUserID"].ToString(); dr[Constant.BarCodeResultTableColumns.out_groutingNum.ToString()] = ds.Tables[0].Rows[0]["GroutingNum"].ToString(); dr[Constant.BarCodeResultTableColumns.out_mouldCode.ToString()] = ds.Tables[0].Rows[0]["MouldCode"].ToString(); dr[Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()] = ds.Tables[0].Rows[0]["ispublicbody"].ToString(); dr[Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()] = "0"; dr[Constant.BarCodeResultTableColumns.out_groutingdate.ToString()] = ds.Tables[0].Rows[0]["Groutingdate"].ToString(); dr[Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()] = ds.Tables[0].Rows[0]["SpecialRepairFlag"].ToString(); dr[Constant.BarCodeResultTableColumns.out_isReFire.ToString()] = "0"; dr[Constant.BarCodeResultTableColumns.out_logoID.ToString()] = ds.Tables[0].Rows[0]["logoid"].ToString(); dr[Constant.BarCodeResultTableColumns.out_logoCode.ToString()] = ds.Tables[0].Rows[0]["logocode"].ToString(); dr[Constant.BarCodeResultTableColumns.out_logoName.ToString()] = ds.Tables[0].Rows[0]["logoname"].ToString(); dr[Constant.BarCodeResultTableColumns.out_deliverLimitCycle.ToString()] = ds.Tables[0].Rows[0]["DeliverLimitCycle"].ToString(); // 首节点无需暂时字段 //barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_WaterLabelCode.ToString()); //barCodeResultTable.Columns.Add(Constant.BarCodeResultTableColumns.out_CodeCheckFlag.ToString()); } } } } dr[Constant.BarCodeResultTableColumns.out_missFlag.ToString()] = 0; dtBarCode.Rows.Add(dr); returnDs.Tables.Add(dtBarCode); return returnDs; } catch (Exception ex) { throw ex; } finally { if (oracleConn.ConnState == ConnectionState.Open) { oracleConn.Close(); } } } /// /// 获取干补标识 /// /// 产品条码ram> /// int public static ServiceResultEntity GetSpecialRepairflagByBarcode(string barcode, SUserInfo sUserInfo) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); string sqlString = @"select SpecialRepairflag from tp_pm_inproduction where barcode=:barcode union select SpecialRepairflag from tp_pm_inproductiontrash where barcode=:barcode union select SpecialRepairflag from tp_pm_finishedproduct where barcode=:barcode "; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; sre.Data = con.GetSqlResultToDs(sqlString, paras); return sre; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 获取产品完成工序的ID(PDA) /// /// 产品条码 /// int public static ServiceResultEntity GetCompleteProcedureIDPDA(string barcode) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); string sqlString = @"select FlowProcedureID as CompleteProcedureID, ProductionDataID, ProcedureID, OPTimeStamp, to_char(OPTimeStamp,'DD-MM-YYHH12.MI.SS.FFAM') as ConvertOPTimeStamp from TP_PM_InProduction where TP_PM_InProduction.BarCode=:BarCode union select FlowProcedureID as CompleteProcedureID, ProductionDataID, ProcedureID, OPTimeStamp, to_char(OPTimeStamp,'DD-MM-YYHH12.MI.SS.FFAM') as ConvertOPTimeStamp from Tp_Pm_Inproductiontrash where Tp_Pm_Inproductiontrash.BarCode=:BarCode "; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":BarCode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; sre.Data = con.GetSqlResultToDs(sqlString, paras); return sre; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 获取产品条码是否重烧 /// /// 产品条码 /// Datase public static ServiceResultEntity GetReFine(string barcode) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { //获取窑炉管理数据 //string sqlString = "Select IsReFire from TP_PM_InProduction where barcode=:barcode"; string sqlString = "select IsReFire, IsLengBu from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode=:barcode)"; Oracle.ManagedDataAccess.Client.OracleParameter[] oracleParameter = new Oracle.ManagedDataAccess.Client.OracleParameter[] { new Oracle.ManagedDataAccess.Client.OracleParameter(":barcode",barcode) }; oracleConn.Open(); sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter); oracleConn.Close(); return sre; } catch (Exception ex) { if (oracleConn.ConnState == ConnectionState.Open) { oracleConn.Close(); } throw ex; } finally { if (oracleConn.ConnState == ConnectionState.Open) { oracleConn.Close(); } } } /// /// 获取次品产品条码允许编辑 /// /// 产品条码 /// Datase public static ServiceResultEntity GetSubstandardInfo(string barcode) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { //获取窑炉管理数据 string sqlString = "Select barcode from TP_PM_InProductionTrash where barcode=:barcode"; Oracle.ManagedDataAccess.Client.OracleParameter[] oracleParameter = new Oracle.ManagedDataAccess.Client.OracleParameter[] { new Oracle.ManagedDataAccess.Client.OracleParameter(":barcode",barcode) }; oracleConn.Open(); sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter); oracleConn.Close(); return sre; } catch (Exception ex) { if (oracleConn.ConnState == ConnectionState.Open) { oracleConn.Close(); } throw ex; } finally { if (oracleConn.ConnState == ConnectionState.Open) { oracleConn.Close(); } } } /// /// 根据条码获取窑炉窑车信息 /// /// 产品条码 /// DataSet public static ServiceResultEntity GetKilnCarByBarCode(string barcode) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); // string sqlString = @" // select // TP_MST_KilnCar.KilnCarCode, // TP_MST_Kiln.KilnCode, // TP_MST_DataDictionary.Dictionaryvalue // from TP_PM_KilnCarGoods // left join TP_MST_KilnCar // on TP_PM_KilnCarGoods.KilnCarID=TP_MST_KilnCar.Kilncarid // left join TP_MST_Kiln // on TP_MST_KilnCar.Kilnid=TP_MST_Kiln.Kilnid // left join TP_MST_DataDictionary // on TP_PM_KilnCarGoods.KilnCarPosition=TP_MST_DataDictionary.DictionaryID // where TP_PM_KilnCarGoods.Barcode=:Barcode // "; string sqlString = @" select TP_PM_InProduction.KilnCarCode, TP_PM_InProduction.KilnCode, TP_MST_DataDictionary.Dictionaryvalue from TP_PM_InProduction inner join TP_MST_DataDictionary on TP_PM_InProduction.KilnCarPosition=TP_MST_DataDictionary.DictionaryID where TP_PM_InProduction.Barcode=:Barcode "; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":Barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; sre.Data = con.GetSqlResultToDs(sqlString, paras); return sre; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 由产品条码获取注浆信息 /// /// 产品条码 /// DataSet public static ServiceResultEntity GetGroutingProducttByBarCode(string barcode) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); string sqlString = @"select TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode, TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum, TP_PM_GroutingDailyDetail.GroutingMouldCode as MouldCode, TP_MST_Logo.logoid, TP_MST_Logo.logocode, TP_MST_Logo.logoname, (select tp_pm_inproduction.ispublicbody from tp_pm_inproduction where tp_pm_inproduction.BarCode=:barcode) as ispublicbody, (select tp_pm_inproductiontrash.ispublicbody from tp_pm_inproductiontrash where tp_pm_inproductiontrash.BarCode=:barcode) as ispublicbodyTrach, TP_PM_GroutingDailyDetail.Groutingdate 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), }; sre.Data = con.GetSqlResultToDs(sqlString, paras); return sre; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 成检时获取条码的产品信息(成检(正品)--报损-->干补-->成检) /// /// 产品条码 /// int public static ServiceResultEntity GetGoodsInfoBybarcode(string barcode) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); string sqlString = @"select GoodsID,GoodsCode,GoodsName, ( select TP_PM_InProduction.SpecialRepairFlag from TP_PM_InProduction where TP_PM_InProduction.BarCode=:BarCode ) SpecialRepairFlag, ( select TP_PM_InProduction.IsReFire from TP_PM_InProduction where TP_PM_InProduction.BarCode=:BarCode ) IsReFire, tp_mst_logo.logoid, tp_mst_logo.logocode, tp_mst_logo.logoname, TP_PM_GroutingDailyDetail.UserCode, TP_PM_GroutingDailyDetail.GroutingMouldCode as MouldCode, TP_PM_GroutingDailyDetail.GroutingCount, TP_PM_GroutingDailyDetail.GroutingDate 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",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; sre.Data = con.GetSqlResultToDs(sqlString, paras); return sre; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 成检时获取条码的产品信息 /// /// 产品条码 /// int public static ServiceResultEntity GetProductionID(string barcode) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); //string sqlString = @"select t.procedureid from TP_PM_INPRODUCTION t // where t.BarCode =:BarCode "; string sqlString = @"select tp.finishedcheckprocedureid as procedureid,t.procedureid as finishedcheckprocedureid from TP_PM_INPRODUCTION t left join tp_pc_procedure tp on t.procedureid = tp.procedureid where t.barcode = :BarCode "; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":BarCode",OracleDbType.Varchar2, barcode,ParameterDirection.Input), }; sre.Data = con.GetSqlResultToDs(sqlString, paras); return sre; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 根据所选工号对应的工种,查出缺陷责任员工 /// /// 工种ID /// 用户ID /// 用户基本信息 /// DataSet public static ServiceResultEntity GetDutyStaffByUserJobsID(int jobs, SUserInfo sUserInfo, int userid) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); string sqlString = @"select TP_HR_Staff.StaffID,TP_HR_Staff.StaffCode,TP_HR_Staff.StaffName,TP_HR_Staff.StaffStatus,TP_MST_UserStaff.UJobsID as SJobsID from TP_MST_UserStaff left join TP_HR_Staff on TP_MST_UserStaff.Staffid=TP_HR_Staff.Staffid where TP_MST_UserStaff.Ujobsid=:jobs and TP_MST_UserStaff.Userid=:userid "; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":jobs",OracleDbType.Int32, jobs,ParameterDirection.Input), new OracleParameter(":userid",OracleDbType.Int32, userid,ParameterDirection.Input), }; sre.Data = con.GetSqlResultToDs(sqlString, paras); return sre; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 根据所选工号,查出漏检责任员工 /// /// 工号 /// 用户基本信息 /// DataSet public static ServiceResultEntity GetMissedStaffByUserID(int userid, SUserInfo sUserInfo) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); string sqlString = @"select TP_HR_Staff.StaffID,TP_HR_Staff.StaffCode,TP_HR_Staff.StaffName,TP_HR_Staff.StaffStatus,TP_MST_UserStaff.UJobsID as UJobsID,TP_HR_Staff.Jobs as SJobsID from TP_MST_UserStaff left join TP_HR_Staff on TP_MST_UserStaff.Staffid=TP_HR_Staff.Staffid where TP_MST_UserStaff.Userid=:userid "; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":userid",OracleDbType.Int32, userid,ParameterDirection.Input), }; sre.Data = con.GetSqlResultToDs(sqlString, paras); return sre; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 数据字典 /// /// /// public static ServiceResultEntity GetDictionaryData(string dicType, string isLeaf) { ServiceResultEntity sre = new ServiceResultEntity(); IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { string sqlString = string.Empty; if ("1".Equals(isLeaf)) { sqlString = "SELECT DICTIONARYID,DICTIONARYVALUE FROM Tp_Mst_Datadictionary WHERE VALUEFLAG = '1' AND ISLEAF = '1' AND DICTIONARYTYPE = :dicType "; } else { sqlString = "SELECT DICTIONARYID,DICTIONARYVALUE FROM Tp_Mst_Datadictionary WHERE VALUEFLAG = '1' AND DICTIONARYTYPE = :dicType "; } OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":dicType", OracleDbType.Varchar2, dicType, ParameterDirection.Input), }; sre.Data = con.GetSqlResultToDs(sqlString, paras); return sre; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } #endregion #region 一览页面查询 /// /// 使用存储过程PRO_PM_GetProductionData获取生产工序计件数据 /// /// 生产数据实体类 /// 用户基本信息 /// DataTable public static ServiceResultEntity GetProductionData(SearchProductionDataEntity searchEntity, SUserInfo user) { IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); ServiceResultEntity sre = new ServiceResultEntity(); string sqlString = ""; //IDataParameter[] paras = null; List parameters = new List(); try { sqlString = @"SELECT DISTINCT t.finishedcheckprocedureid FROM tp_pc_procedure t WHERE t.finishedcheckprocedureid IS NOT NULL "; DataSet ProcedureIDSets = oracleConn.GetSqlResultToDs(sqlString); string id = ""; if (ProcedureIDSets != null && ProcedureIDSets.Tables.Count > 0 && ProcedureIDSets.Tables[0].Rows.Count > 0) { for (int i = 0; i < ProcedureIDSets.Tables[0].Rows.Count; i++) { string finishedcheckprocedureid = ProcedureIDSets.Tables[0].Rows[i]["finishedcheckprocedureid"]+""; if (string.IsNullOrEmpty(id)) { id += finishedcheckprocedureid; } else { id += "," + finishedcheckprocedureid; } } } if (id.Length >0) { sqlString = @"SELECT TP_PM_PRODUCTIONDATA.CREATETIME ,TP_PM_PRODUCTIONDATA.UPDATETIME ,TP_PM_PRODUCTIONDATA.PRODUCTIONDATAID ,TP_PM_PRODUCTIONDATA.PRODUCTIONLINECODE ,TP_PM_PRODUCTIONDATA.BARCODE ,TP_PM_PRODUCTIONDATA.GOODSCODE ,TP_PM_PRODUCTIONDATA.GOODSNAME ,TP_PM_PRODUCTIONDATA.USERCODE ,TP_PM_PRODUCTIONDATA.ISPUBLICBODY ,DECODE(TP_PM_PRODUCTIONDATA.PROCEDUREMODEL ,'1 ' ,'计数模型' ,'检验模型') AS PROCEDUREMODEL ,TP_SYS_PROCEDUREMODELTYPE.PROCEDUREMODELTYPENAME ,DECODE(TP_PM_PRODUCTIONDATA.PIECETYPE ,'1' ,'不计件' ,'同工种策略') AS PIECETYPE ,TP_PM_PRODUCTIONDATA.ISREWORKED ,TP_MST_GOODSLEVEL.GOODSLEVELNAME AS GOODSGRADE ,TP_MST_ORGANIZATION.ORGANIZATIONNAME ,TP_PM_PRODUCTIONDATA.REMARKS ,TP_PM_PRODUCTIONDATA.KILNID ,TP_PM_PRODUCTIONDATA.KILNCODE ,TP_PM_PRODUCTIONDATA.KILNNAME ,TP_PM_PRODUCTIONDATA.KILNCARID ,TP_PM_PRODUCTIONDATA.KILNCARCODE ,TP_PM_PRODUCTIONDATA.KILNCARNAME ,TP_PM_PRODUCTIONDATA.KILNCARPOSITION ,TP_PM_PRODUCTIONDATA.KILNCARBATCHNO ,TP_MST_DATADICTIONARY.DICTIONARYVALUE KILNCARPOSITIONNAME ,TP_MST_GOODSTYPE.GOODSTYPENAME ,TP_MST_USER.USERCODE AS BARUSERCODE ,TP_PM_PRODUCTIONDATA.GROUTINGUSERCODE ,TP_PM_PRODUCTIONDATA.GROUTINGMOULDCODE ,TP_PM_PRODUCTIONDATA.GROUTINGDATE ,TP_PM_PRODUCTIONDATA.GROUTINGNUM ,TP_MST_USER.USERNAME AS BARUSERNAME ,TP_MST_GOODSLEVEL.GOODSLEVELNAME AS GOODSLEVELTYPE ,REPLACE((TP_MST_LOGO.LOGONAME || '[' || TP_MST_LOGO.LOGOCODE || ']') ,'[]' ,'') AS LOGOCODENAME ,TP_PM_PRODUCTIONDATA.SPECIALREPAIRFLAG ,PCP.PROCEDURENAME INPROCEDURENAME FROM TP_PM_PRODUCTIONDATA LEFT JOIN TP_PM_INPRODUCTION INP ON INP.BARCODE = TP_PM_PRODUCTIONDATA.BARCODE LEFT JOIN TP_PC_PROCEDURE PCP ON PCP.PROCEDUREID = INP.PROCEDUREID LEFT JOIN TP_SYS_PROCEDUREMODELTYPE ON TP_PM_PRODUCTIONDATA.MODELTYPE = TP_SYS_PROCEDUREMODELTYPE.PROCEDUREMODELTYPEID LEFT JOIN TP_MST_ORGANIZATION ON TP_PM_PRODUCTIONDATA.ORGANIZATIONID = TP_MST_ORGANIZATION.ORGANIZATIONID LEFT JOIN TP_MST_DATADICTIONARY ON TP_PM_PRODUCTIONDATA.KILNCARPOSITION = TP_MST_DATADICTIONARY.DICTIONARYID LEFT JOIN TP_MST_GOODSLEVEL ON TP_PM_PRODUCTIONDATA.GOODSLEVELID = TP_MST_GOODSLEVEL.GOODSLEVELID LEFT JOIN TP_MST_GOODS ON TP_PM_PRODUCTIONDATA.GOODSID = TP_MST_GOODS.GOODSID LEFT JOIN TP_MST_GOODSTYPE ON TP_MST_GOODS.GOODSTYPEID = TP_MST_GOODSTYPE.GOODSTYPEID LEFT JOIN TP_MST_USER ON TP_PM_PRODUCTIONDATA.CREATEUSERID = TP_MST_USER.USERID LEFT JOIN TP_MST_LOGO ON TP_PM_PRODUCTIONDATA.LOGOID = TP_MST_LOGO.LOGOID WHERE TP_PM_PRODUCTIONDATA.VALUEFLAG = '1' AND TP_PM_PRODUCTIONDATA.FINISHEDPROCEDUREID IS NOT NULL"; sqlString += " AND TP_PM_PRODUCTIONDATA.PROCEDUREID in (" + id + ") " + " AND(TP_PM_PRODUCTIONDATA.CREATETIME >= :begindate AND " +" TP_PM_PRODUCTIONDATA.CREATETIME <= :enddate) "; parameters.Add(new OracleParameter(":begindate", OracleDbType.Date, searchEntity.BeginDate, ParameterDirection.Input)); parameters.Add(new OracleParameter(":enddate", OracleDbType.Date, searchEntity.EndDate, ParameterDirection.Input)); if (!string.IsNullOrEmpty(searchEntity.BarCode)) { sqlString = sqlString + " AND TP_PM_PRODUCTIONDATA.BARCODE = :barCode "; parameters.Add(new OracleParameter(":barCode", OracleDbType.Varchar2, searchEntity.BarCode, ParameterDirection.Input)); } if (!string.IsNullOrEmpty(searchEntity.GoodsCode)) { sqlString = sqlString + " AND INSTR(TP_PM_PRODUCTIONDATA.GOODSCODE, :goodsCode) > 0 "; parameters.Add(new OracleParameter(":goodsCode", OracleDbType.Varchar2, searchEntity.GoodsCode, ParameterDirection.Input)); } if (!string.IsNullOrEmpty(searchEntity.GoodsName)) { sqlString = sqlString + " AND INSTR(TP_PM_PRODUCTIONDATA.GOODSNAME, :goodsName) > 0 "; parameters.Add(new OracleParameter(":goodsName", OracleDbType.Varchar2, searchEntity.GoodsName, ParameterDirection.Input)); } if (!string.IsNullOrEmpty(searchEntity.UserCode)) { sqlString = sqlString + " AND INSTR(TP_PM_PRODUCTIONDATA.USERCODE, :userCode) > 0 "; parameters.Add(new OracleParameter(":userCode", OracleDbType.Varchar2, searchEntity.UserCode, ParameterDirection.Input)); } if (!string.IsNullOrEmpty(searchEntity.OrganizationID + "")) { sqlString = sqlString + " AND ( :organizationID = 0 OR TP_PM_PRODUCTIONDATA.ORGANIZATIONID = :organizationID ) "; parameters.Add(new OracleParameter(":organizationID", OracleDbType.Int32, searchEntity.OrganizationID, ParameterDirection.Input)); } if (!string.IsNullOrEmpty(searchEntity.Remarks)) { sqlString = sqlString + " AND INSTR(TP_PM_PRODUCTIONDATA.REMARKS, :remarks) > 0 "; parameters.Add(new OracleParameter(":remarks", OracleDbType.Varchar2, searchEntity.Remarks, ParameterDirection.Input)); } if (!string.IsNullOrEmpty(searchEntity.IsRework)) { sqlString = sqlString + " AND INSTR( :isReworked, TP_PM_PRODUCTIONDATA.ISREWORKED) > 0 "; parameters.Add(new OracleParameter(":isReworked", OracleDbType.Varchar2, searchEntity.IsRework, ParameterDirection.Input)); } if (!string.IsNullOrEmpty(searchEntity.KilnCode)) { sqlString = sqlString + " AND TP_PM_PRODUCTIONDATA.KILNCODE = :pKilnCode "; parameters.Add(new OracleParameter(":pKilnCode", OracleDbType.Varchar2, searchEntity.KilnCode, ParameterDirection.Input)); } if (!string.IsNullOrEmpty(searchEntity.KilnCarCode)) { sqlString = sqlString + " AND TP_PM_PRODUCTIONDATA.KILNCARCODE = :pKilnCarCode "; parameters.Add(new OracleParameter(":pKilnCarCode", OracleDbType.Varchar2, searchEntity.KilnCarCode, ParameterDirection.Input)); } if (!string.IsNullOrEmpty(searchEntity.KilnCarPosition + "")) { sqlString = sqlString + " AND TP_PM_PRODUCTIONDATA.KILNCARPOSITION = :pKilnCarPosition "; parameters.Add(new OracleParameter(":pKilnCarPosition", OracleDbType.Int32, searchEntity.KilnCarPosition, ParameterDirection.Input)); } if (!string.IsNullOrEmpty(searchEntity.KilnCarPosition + "")) { sqlString = sqlString + " AND TP_PM_PRODUCTIONDATA.KILNCARPOSITION = :pKilnCarPosition "; parameters.Add(new OracleParameter(":pKilnCarPosition", OracleDbType.Int32, searchEntity.KilnCarPosition, ParameterDirection.Input)); } if (!string.IsNullOrEmpty(user.UserID + "")) { sqlString = sqlString + @" AND ( TP_PM_PRODUCTIONDATA.CREATEUSERID = : userID OR EXISTS ( SELECT 1 FROM TP_MST_USERPURVIEW UP WHERE UP.PURVIEWTYPE = 4 AND ( UP.PURVIEWID = - 1 OR UP.PURVIEWID = TP_PM_PRODUCTIONDATA.CREATEUSERID ) AND UP.USERID = : userID ) ) "; parameters.Add(new OracleParameter(":userID", OracleDbType.Int32, user.UserID, ParameterDirection.Input)); } if (!string.IsNullOrEmpty(searchEntity.GoodsTypeCode)) { sqlString = sqlString + " AND INSTR(TP_MST_GOODSTYPE.GOODSTYPECODE, :goodstypecode) > 0 "; parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, searchEntity.GoodsTypeCode, ParameterDirection.Input)); } oracleConn.Open(); DataSet ds = oracleConn.GetSqlResultToDs(sqlString, parameters.ToArray()); sre.Data = ds; } return sre; } catch (Exception ex) { throw ex; } finally { if (oracleConn.ConnState == ConnectionState.Open) { oracleConn.Close(); } } } /// /// 撤销 /// /// 工序ID /// 生产数据集 /// 用户基本信息 /// string public static ServiceResultEntity FinishedCancleData(int productionDataID, SUserInfo sUserInfo) { ServiceResultEntity sre = new ServiceResultEntity(); string errMsg = ""; IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString); try { oracleTrConn.Connect(); string sqlString = "UPDATE TP_PM_ProductionDataIn t\n" + " SET t.valueFlag = '0'\n" + " WHERE t.productiondataid = " + productionDataID; sre.OtherStatus = oracleTrConn.ExecuteNonQuery(sqlString); // 没有错误 提交事务 if (string.IsNullOrEmpty(errMsg)) { oracleTrConn.Commit(); } } catch (Exception ex) { oracleTrConn.Rollback(); throw ex; } finally { // 释放资源 if (oracleTrConn.ConnState == System.Data.ConnectionState.Open) { oracleTrConn.Disconnect(); } } return sre; } #endregion #region 撤销接口-查询 /// /// 撤销接口-查询 /// /// 生产数据实体类 /// 用户基本信息 /// DataTable public static ServiceResultEntity GetFinishedCancleData(string barCode, SUserInfo user) { IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); ServiceResultEntity sre = new ServiceResultEntity(); string sqlString = ""; List parameters = new List(); try { sqlString = @"SELECT to_char( TP_PM_PRODUCTIONDATA.PRODUCTIONDATAID) as PRODUCTIONDATAID ,TP_MST_USER.USERNAME AS BARUSERNAME ,TP_MST_GOODSLEVEL.GOODSLEVELNAME AS GOODSLEVELTYPE ,PCP.PROCEDURENAME INPROCEDURENAME ,TP_MST_GOODSTYPE.GOODSTYPENAME FROM TP_PM_PRODUCTIONDATA LEFT JOIN TP_PM_INPRODUCTION INP ON INP.BARCODE = TP_PM_PRODUCTIONDATA.BARCODE LEFT JOIN TP_PC_PROCEDURE PCP ON PCP.PROCEDUREID = INP.PROCEDUREID LEFT JOIN TP_MST_GOODSLEVEL ON TP_PM_PRODUCTIONDATA.GOODSLEVELID = TP_MST_GOODSLEVEL.GOODSLEVELID LEFT JOIN TP_MST_GOODS ON TP_PM_PRODUCTIONDATA.GOODSID = TP_MST_GOODS.GOODSID LEFT JOIN TP_MST_GOODSTYPE ON TP_MST_GOODS.GOODSTYPEID = TP_MST_GOODSTYPE.GOODSTYPEID LEFT JOIN TP_MST_USER ON TP_PM_PRODUCTIONDATA.CREATEUSERID = TP_MST_USER.USERID WHERE TP_PM_PRODUCTIONDATA.VALUEFLAG = '1' AND TP_PM_PRODUCTIONDATA.FINISHEDPROCEDUREID IS NOT NULL AND TP_PM_PRODUCTIONDATA.BARCODE = :barCode "; parameters.Add(new OracleParameter(":barCode", OracleDbType.Varchar2, barCode, ParameterDirection.Input)); if (!string.IsNullOrEmpty(user.UserID + "")) { sqlString = sqlString + @" AND ( TP_PM_PRODUCTIONDATA.CREATEUSERID = :userID OR EXISTS ( SELECT 1 FROM TP_MST_USERPURVIEW UP WHERE UP.PURVIEWTYPE = 4 AND ( UP.PURVIEWID = - 1 OR UP.PURVIEWID = TP_PM_PRODUCTIONDATA.CREATEUSERID ) AND UP.USERID = :userID ) ) "; parameters.Add(new OracleParameter(":userID", OracleDbType.Int32, user.UserID, ParameterDirection.Input)); } sqlString = sqlString + @" order by TP_PM_PRODUCTIONDATA.CREATETIME desc "; oracleConn.Open(); DataSet ds = oracleConn.GetSqlResultToDs(sqlString, parameters.ToArray()); sre.Data = ds; return sre; } catch (Exception ex) { throw ex; } finally { if (oracleConn.ConnState == ConnectionState.Open) { oracleConn.Close(); } } } #endregion } }