|  |  |  | 
|---|
|  |  |  | Gy_RoutingBill_temporary omdelMian = new Gy_RoutingBill_temporary(); | 
|---|
|  |  |  | public string BillType = "3301"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 工艺路线 列表 | 
|---|
|  |  |  | #region 未知 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 返回工艺路线列表 | 
|---|
|  |  |  | /// 未知 | 
|---|
|  |  |  | ///参数:string sql。 | 
|---|
|  |  |  | ///返回值:object。 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (sWhere == null || sWhere.Equals("")) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_MES_StationEntrustOutBillList " + sWhere, "h_v_MES_StationEntrustOutBillList"); | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select  * from h_v_MES_StationEntrustOutBillList " + sWhere, "h_v_MES_StationEntrustOutBillList"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string sql1 = "select * from h_v_MES_StationEntrustOutBillList where 1 = 1 "; | 
|---|
|  |  |  | string sql1 = "select  * from h_v_MES_StationEntrustOutBillList where 1 = 1 "; | 
|---|
|  |  |  | string sql = sql1 + sWhere; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_MES_StationEntrustOutBillList"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | string msg2 = sArray[0].ToString(); | 
|---|
|  |  |  | string msg3 = sArray[1].ToString(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int hentryid = int.Parse(sArray[2].ToString());//子表的顺序id | 
|---|
|  |  |  | int OperationType = int.Parse(sArray[3].ToString());//数据类型 1添加 3修改 | 
|---|
|  |  |  | string user = sArray[4].ToString();//用户名 | 
|---|
|  |  |  | //int hentryid = int.Parse(sArray[2].ToString());//子表的顺序id | 
|---|
|  |  |  | int OperationType = int.Parse(sArray[2].ToString());//数据类型 1添加 3修改 | 
|---|
|  |  |  | string user = sArray[3].ToString();//用户名 | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断是否有编辑权限 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | msg2 = "[" + msg2.ToString() + "]"; | 
|---|
|  |  |  | List<Gy_RoutingBill> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Gy_RoutingBill>>(msg2); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | long HInterID = mainList[0].HInterID;//递入type得到的单据ID | 
|---|
|  |  |  | string HBillNo = mainList[0].HBillNo;//递入type得到的单据号 | 
|---|
|  |  |  | DateTime HDate = mainList[0].HDate;//日期 | 
|---|
|  |  |  | 
|---|
|  |  |  | double HStdSourceQty = mainList[0].HStdSourceQty;//标准资源数 | 
|---|
|  |  |  | double HAddSourceRate = mainList[0].HAddSourceRate;//加资源增量 | 
|---|
|  |  |  | double HDelSourceRate = mainList[0].HDelSourceRate;//减资源减量 | 
|---|
|  |  |  | int HPRDORGID = mainList[0].HPRDORGID;  //生产组织 | 
|---|
|  |  |  | int HPRDORGID = mainList[0].HOrgID;  //生产组织 | 
|---|
|  |  |  | int HOrgID = mainList[0].HOrgID;  //组织 | 
|---|
|  |  |  | string HPicNumVer = mainList[0].HPicNumVer;//图号版本 | 
|---|
|  |  |  | string HPicNumAssemble = mainList[0].HPicNumAssemble;//总装图号 | 
|---|
|  |  |  | 
|---|
|  |  |  | string HProductNum = mainList[0].HProductNum;//成品编号 | 
|---|
|  |  |  | string HVerNum = mainList[0].HVerNum;//版本 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (OperationType == 1)//新增 | 
|---|
|  |  |  | if (OperationType == 2) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_Gy_RoutingBillList where  单据号='" + HBillNo + "'", "h_v_Gy_RoutingBillList"); | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count > 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "单据号重复,请重新输入!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_Gy_RoutingBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_Gy_RoutingBillList"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//新增 | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //主表 | 
|---|
|  |  |  | oCN.RunProc("Insert Into Gy_RoutingBillMain   " + | 
|---|
|  |  |  | 
|---|
|  |  |  | "," + HRoutingGroupID + "," + HUnitID + ",'" + HMaterNumber + "','" + HUnitNumber + "'," + Convert.ToString(HStandard ? 1 : 0) + | 
|---|
|  |  |  | "," + HMainGroupID + "," + HMainProcID + "," + HMainCenterID + ",'" + HMainTimeUnit + "'," + HMainUnitTime + "," + HMainWorkQty + | 
|---|
|  |  |  | "," + HMainPrice + "," + HStdSourceQty + "," + HAddSourceRate + "," + HPRDORGID + "," + HDelSourceRate + | 
|---|
|  |  |  | ",'"+ HPicNumVer + "','" + HPicNumAssemble + "','" + HMaterTexture + "','" + HProductNum + "','" + HVerNum + "',"+ HOrgID + ") "); | 
|---|
|  |  |  | ",'" + HPicNumVer + "','" + HPicNumAssemble + "','" + HMaterTexture + "','" + HProductNum + "','" + HVerNum + "'," + HOrgID + ") "); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (OperationType == 3) | 
|---|
|  |  |  | else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0) | 
|---|
|  |  |  | { //修改 | 
|---|
|  |  |  | oCN.RunProc("update Gy_RoutingBillMain  set " + | 
|---|
|  |  |  | "HDate='" + HDate + | 
|---|
|  |  |  | 
|---|
|  |  |  | ",HProductNum='" + HProductNum + "',HVerNum='" + HVerNum + "' where HInterID='" + HInterID + "'"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //删除子表 | 
|---|
|  |  |  | oCN.RunProc("delete from Gy_RoutingBillSub where HInterID='" + HInterID + "' and HEntryID='" + hentryid + "'"); | 
|---|
|  |  |  | oCN.RunProc("delete from Gy_RoutingBillSub where HInterID='" + HInterID + "' and HProcNo!='9999'"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //保存子表 | 
|---|
|  |  |  | objJsonResult = AddBillSub(msg3, HInterID, hentryid); | 
|---|
|  |  |  | objJsonResult = AddBillSub(msg3, HInterID, OperationType); | 
|---|
|  |  |  | if (objJsonResult.code == "0") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (OperationType == 1) | 
|---|
|  |  |  | { | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (ds == null || ds.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public json AddBillSub(string msg3, long HInterID, int hentryid) | 
|---|
|  |  |  | public json AddBillSub(string msg3, long HInterID,int OperationType) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<Gy_RoutingBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Gy_RoutingBillSub>>(msg3); | 
|---|
|  |  |  | int i = 0; | 
|---|
|  |  |  | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | oCN.RunProc("Insert into Gy_RoutingBillSub " + | 
|---|
|  |  |  | "(HInterID,HEntryID,HProcID,HProcNO,HSupID,HSupFlag" + | 
|---|
|  |  |  | ",HWorkQty,HCenterID,HTimeUnit,HUnitTime" + | 
|---|
|  |  |  | ",HReadyTime,HQueueTime,HMoveTime" + | 
|---|
|  |  |  | ",HCloseMan,HCloseType,HRemark,HProcType,HNextProcFlag,HFlowProc" + | 
|---|
|  |  |  | ",HFixPrice,HProcPrice,HBadPrice,HWasterPrice,HStdFlag,HBeginDayQty,HBeginFixQty" + | 
|---|
|  |  |  | ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HAutoTrunFlag" + | 
|---|
|  |  |  | ",HFixWorkDays,HTrunWorkDays,HReadyTimes,HICMOReadyTimes,HSubStdEmpQty,HSubCanUseSourceQty" + | 
|---|
|  |  |  | ",HProcID_S,HCenterID_S,HWorkQty_S,HSubStdEmpQty_S,HMouldNo,HChangeMould" + | 
|---|
|  |  |  | ",HPackStd,HPack,HPutArea,HMyWorkDays,HMyFixWorkDays,HPassRate" + | 
|---|
|  |  |  | ",HTechnologyParameter,HPicNum,HProcCheckNote" + | 
|---|
|  |  |  | ",HOverRate,HProcWorkNum" + | 
|---|
|  |  |  | ") values(" | 
|---|
|  |  |  | + HInterID + "," + (hentryid==-1?i: hentryid) + "," + oSub.HProcID.ToString() + ",'" + (hentryid == -1 ? i : hentryid) + "'," + oSub.HSupID.ToString() + "," + Convert.ToString(oSub.HSupFlag ? 1 : 0) + "" + | 
|---|
|  |  |  | "," + oSub.HWorkQty.ToString() + "," + oSub.HCenterID.ToString() + ",'" + oSub.HTimeUnit.ToString() + "'," + oSub.HUnitTime.ToString() + | 
|---|
|  |  |  | "," + oSub.HReadyTime.ToString() + "," + oSub.HQueueTime.ToString() + "," + oSub.HMoveTime.ToString() + | 
|---|
|  |  |  | ",'" + oSub.HCloseMan + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "','" + oSub.HProcType + "'," + Convert.ToString(oSub.HNextProcFlag ? 1 : 0) + "," + Convert.ToString(oSub.HFlowProc ? 1 : 0) + | 
|---|
|  |  |  | "," + oSub.HFixPrice.ToString() + "," + oSub.HProcPrice.ToString() + "," + oSub.HBadPrice.ToString() + "," + oSub.HWasterPrice.ToString() + "," + Convert.ToString(oSub.HStdFlag ? 1 : 0) + "," + oSub.HBeginDayQty.ToString() + "," + oSub.HBeginFixQty.ToString() + | 
|---|
|  |  |  | "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() + "," + Convert.ToString(oSub.HAutoTrunFlag ? 1 : 0) + | 
|---|
|  |  |  | "," + oSub.HFixWorkDays.ToString() + "," + oSub.HTrunWorkDays.ToString() + "," + oSub.HReadyTimes.ToString() + "," + oSub.HICMOReadyTimes.ToString() + "," + oSub.HSubStdEmpQty.ToString() + "," + oSub.HSubCanUseSourceQty.ToString() + | 
|---|
|  |  |  | "," + oSub.HProcID_S.ToString() + "," + oSub.HCenterID_S.ToString() + "," + oSub.HWorkQty_S.ToString() + ", " + oSub.HSubStdEmpQty_S.ToString() + ",'" + oSub.HMouldNo + "'," + oSub.HChangeMould.ToString() + | 
|---|
|  |  |  | ",'" + oSub.HPackStd + "','" + oSub.HPack + "','" + oSub.HPutArea + "'," + oSub.HMyWorkDays.ToString() + "," + oSub.HMyFixWorkDays.ToString() + "," + oSub.HPassRate.ToString() + | 
|---|
|  |  |  | ",'" + oSub.HTechnologyParameter.ToString() + "','" + oSub.HPicNum.ToString() + "','" + oSub.HProcCheckNote.ToString() + | 
|---|
|  |  |  | "', " + oSub.HOverRate.ToString() + ",'" + oSub.HProcWorkNum.ToString() + "'" + | 
|---|
|  |  |  | ") "); | 
|---|
|  |  |  | if (oSub.HProcNo != "9999" || OperationType == 2) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.RunProc("Insert into Gy_RoutingBillSub " + | 
|---|
|  |  |  | "(HInterID,HEntryID,HProcID,HProcNO,HSupID,HSupFlag" + | 
|---|
|  |  |  | ",HWorkQty,HCenterID,HTimeUnit,HUnitTime" + | 
|---|
|  |  |  | ",HReadyTime,HQueueTime,HMoveTime" + | 
|---|
|  |  |  | ",HCloseMan,HCloseType,HRemark,HProcType,HNextProcFlag,HFlowProc" + | 
|---|
|  |  |  | ",HFixPrice,HProcPrice,HBadPrice,HWasterPrice,HStdFlag,HBeginDayQty,HBeginFixQty" + | 
|---|
|  |  |  | ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HAutoTrunFlag" + | 
|---|
|  |  |  | ",HFixWorkDays,HTrunWorkDays,HReadyTimes,HICMOReadyTimes,HSubStdEmpQty,HSubCanUseSourceQty" + | 
|---|
|  |  |  | ",HProcID_S,HCenterID_S,HWorkQty_S,HSubStdEmpQty_S,HMouldNo,HChangeMould" + | 
|---|
|  |  |  | ",HPackStd,HPack,HPutArea,HMyWorkDays,HMyFixWorkDays,HPassRate" + | 
|---|
|  |  |  | ",HTechnologyParameter,HPicNum,HProcCheckNote" + | 
|---|
|  |  |  | ",HOverRate,HProcWorkNum" + | 
|---|
|  |  |  | ") values(" | 
|---|
|  |  |  | + HInterID + "," + i + "," + oSub.HProcID.ToString() + ",'" + oSub.HProcNo + "'," + oSub.HSupID.ToString() + "," + Convert.ToString(oSub.HSupFlag ? 1 : 0) + "" + | 
|---|
|  |  |  | "," + oSub.HWorkQty.ToString() + "," + oSub.HCenterID.ToString() + ",'" + oSub.HTimeUnit.ToString() + "'," + oSub.HUnitTime.ToString() + | 
|---|
|  |  |  | "," + oSub.HReadyTime.ToString() + "," + oSub.HQueueTime.ToString() + "," + oSub.HMoveTime.ToString() + | 
|---|
|  |  |  | ",'" + oSub.HCloseMan + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "','" + oSub.HProcType + "'," + Convert.ToString(oSub.HNextProcFlag ? 1 : 0) + "," + Convert.ToString(oSub.HFlowProc ? 1 : 0) + | 
|---|
|  |  |  | "," + oSub.HFixPrice.ToString() + "," + oSub.HProcPrice.ToString() + "," + oSub.HBadPrice.ToString() + "," + oSub.HWasterPrice.ToString() + "," + Convert.ToString(oSub.HStdFlag ? 1 : 0) + "," + oSub.HBeginDayQty.ToString() + "," + oSub.HBeginFixQty.ToString() + | 
|---|
|  |  |  | "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() + "," + Convert.ToString(oSub.HAutoTrunFlag ? 1 : 0) + | 
|---|
|  |  |  | "," + oSub.HFixWorkDays.ToString() + "," + oSub.HTrunWorkDays.ToString() + "," + oSub.HReadyTimes.ToString() + "," + oSub.HICMOReadyTimes.ToString() + "," + oSub.HSubStdEmpQty.ToString() + "," + oSub.HSubCanUseSourceQty.ToString() + | 
|---|
|  |  |  | "," + oSub.HProcID_S.ToString() + "," + oSub.HCenterID_S.ToString() + "," + oSub.HWorkQty_S.ToString() + ", " + oSub.HSubStdEmpQty_S.ToString() + ",'" + oSub.HMouldNo + "'," + oSub.HChangeMould.ToString() + | 
|---|
|  |  |  | ",'" + oSub.HPackStd + "','" + oSub.HPack + "','" + oSub.HPutArea + "'," + oSub.HMyWorkDays.ToString() + "," + oSub.HMyFixWorkDays.ToString() + "," + oSub.HPassRate.ToString() + | 
|---|
|  |  |  | ",'" + oSub.HTechnologyParameter.ToString() + "','" + oSub.HPicNum.ToString() + "','" + oSub.HProcCheckNote.ToString() + | 
|---|
|  |  |  | "', " + oSub.HOverRate.ToString() + ",'" + oSub.HProcWorkNum.ToString() + "'" + | 
|---|
|  |  |  | ") "); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | 
|---|
|  |  |  | file.SaveAs(ExcelPath); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | NpoiHelper np = new NpoiHelper(); | 
|---|
|  |  |  | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1,2, WorkBookName); | 
|---|
|  |  |  | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 2, WorkBookName); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //删除文件 | 
|---|
|  |  |  | File.Delete(ExcelPath); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //创建临时表 | 
|---|
|  |  |  | DataTable tb2 = new DataTable("dt2"); | 
|---|
|  |  |  | DataTable tb3 = new DataTable("dt3"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //添加列名 | 
|---|
|  |  |  | for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!tb2.Columns.Contains("工序")) | 
|---|
|  |  |  | error += "没有找到【工序】的标题,"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!tb2.Columns.Contains("工作中心")) | 
|---|
|  |  |  | error += "没有找到【工作中心】的标题,"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = $"Excel模板存在错误,{error}\r\n" ; | 
|---|
|  |  |  | objJsonResult.Message = $"Excel模板存在错误,{error}\r\n"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //删除临时表数据 | 
|---|
|  |  |  | oCN.RunProc("delete from diyipi"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //临时表添加数据 | 
|---|
|  |  |  | for (int i = 0; i < tb2.Rows.Count; i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.RunProc(@"insert into diyipi(产品代码,产品名称,工序序号,工序代码,工序,工作中心,加工数量 | 
|---|
|  |  |  | , 良率, 工序工价, 不合格单价, 报废单价, 本道固定开工天数, 本道开工余量, 上道等待天数 | 
|---|
|  |  |  | , 上道循环周期, 自动转移, 外协标记, 供应商代码, 供应商, 工艺参数, 图纸编号 | 
|---|
|  |  |  | , 本工序确认记录, 备注, 图号版本, 总装图号, 材质, 成品编号, 版本 | 
|---|
|  |  |  | , 模具编号, 程序号, 班产定额, 工艺路线名称, 时间单位,工艺路线代码)values | 
|---|
|  |  |  | ('" + tb2.Rows[i]["产品代码"].ToString() + "','" + tb2.Rows[i]["产品名称"].ToString() + "','" + tb2.Rows[i]["工序序号"].ToString() + "','" + tb2.Rows[i]["工序代码"].ToString() + "','" + tb2.Rows[i]["工序"].ToString() + "','" + tb2.Rows[i]["工作中心"].ToString() + "','" + tb2.Rows[i]["加工数量"].ToString() + "'" + | 
|---|
|  |  |  | ",'" + tb2.Rows[i]["良率"].ToString() + "','" + (tb2.Rows[i]["工序工价"].ToString() == "" ? "0" : tb2.Rows[i]["工序工价"].ToString()) + "','" + tb2.Rows[i]["不合格单价"].ToString() + "','" + tb2.Rows[i]["报废单价"].ToString() + "','" + tb2.Rows[i]["本道固定开工天数"].ToString() + "','" + tb2.Rows[i]["本道开工余量"].ToString() + "','" + tb2.Rows[i]["上道等待天数"].ToString() + "'" + | 
|---|
|  |  |  | ",'" + tb2.Rows[i]["上道循环周期"].ToString() + "','" + tb2.Rows[i]["自动转移"].ToString() + "','" + tb2.Rows[i]["外协标记"].ToString() + "','" + tb2.Rows[i]["供应商代码"].ToString() + "','" + tb2.Rows[i]["供应商"].ToString() + "','" + tb2.Rows[i]["工艺参数"].ToString() + "','" + tb2.Rows[i]["图纸编号"].ToString() + "'" + | 
|---|
|  |  |  | ",'" + tb2.Rows[i]["本工序确认记录"].ToString() + "','" + tb2.Rows[i]["备注"].ToString() + "','" + tb2.Rows[i]["图号版本"].ToString() + "','" + tb2.Rows[i]["总装图号"].ToString() + "','" + tb2.Rows[i]["材质"].ToString() + "','" + tb2.Rows[i]["成品编号"].ToString() + "','" + tb2.Rows[i]["版本"].ToString() + "'" + | 
|---|
|  |  |  | ",'" + tb2.Rows[i]["模具编号"].ToString() + "','" + tb2.Rows[i]["程序号"].ToString() + "','" + tb2.Rows[i]["班产定额"].ToString() + "','" + tb2.Rows[i]["工艺路线名称"].ToString() + "','" + tb2.Rows[i]["时间单位"].ToString() + "','" + tb2.Rows[i]["工艺路线代码"].ToString() + "')"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | 
|---|
|  |  |  | public string HPeriod; | 
|---|
|  |  |  | public string DataAppend; | 
|---|
|  |  |  | public string HOrgID; | 
|---|
|  |  |  | public Int64 HTProcessFlag; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | [Route("Gy_RoutingBill/Gy_RoutingBill_btnSave")] | 
|---|
|  |  |  | 
|---|
|  |  |  | //表头字段 | 
|---|
|  |  |  | omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<Gy_RoutingBill_temporary>(msg2); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //JSON序列化转换字典集合 | 
|---|
|  |  |  | List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); | 
|---|
|  |  |  | List<object> jb = JsonConvert.DeserializeObject<List<object>>(msg3); | 
|---|
|  |  |  | foreach (JObject item in jb) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select  distinct 产品代码,isnull(工艺路线代码,'') 工艺路线代码 from  diyipi ", "diyipi"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (int i = 0; i < ds.Tables[0].Rows.Count; i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dictionary<string, string> dic = new Dictionary<string, string>(); | 
|---|
|  |  |  | foreach (var itm in item.Properties()) | 
|---|
|  |  |  | var HBillNo = ds.Tables[0].Rows[i]["工艺路线代码"].ToString();//获得一个新的单据号 | 
|---|
|  |  |  | if (HBillNo == "") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | dic.Add(itm.Name, itm.Value.ToString()); | 
|---|
|  |  |  | DataSet dataSet = oCN.RunProcReturn($"select HBillNo  from  Gy_RoutingBillMain where HBillNo='1' ", "Gy_RoutingBillMain"); | 
|---|
|  |  |  | while (1 == 1) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (HBillNo != "") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (dataSet.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | HBillNo = DBUtility.ClsPub.CreateBillCode(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true); | 
|---|
|  |  |  | dataSet = oCN.RunProcReturn($"select HBillNo  from  Gy_RoutingBillMain where HBillNo='{HBillNo}' ", "Gy_RoutingBillMain"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | list.Add(dic); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var hnumber = ""; | 
|---|
|  |  |  | var HBillNo = ""; | 
|---|
|  |  |  | long HInterID = 0; | 
|---|
|  |  |  | int[] num = new int[2] { 1, 0 }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (int i = 0; i < list.Count; i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //获取物料数据 | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_IF_Material Where HNumber='" + list[i]["产品代码"].ToString() + "' and HUSEORGID=" + omdelMian.HOrgID, "h_v_IF_Material"); | 
|---|
|  |  |  | var HMaterNumber = list[i]["产品代码"].ToString(); | 
|---|
|  |  |  | var HMaterID = ds.Tables[0].Rows[0]["HItemID"].ToString(); | 
|---|
|  |  |  | var Hunitid = ds.Tables[0].Rows[0]["Hunitid"].ToString(); | 
|---|
|  |  |  | var HUnitNumber = ds.Tables[0].Rows[0]["HUnitNumber"].ToString(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var HName = list[i]["工艺路线名称"].ToString(); | 
|---|
|  |  |  | var HPicNumVer = list[i]["图号版本"].ToString(); | 
|---|
|  |  |  | var HPicNumAssemble = list[i]["总装图号"].ToString(); | 
|---|
|  |  |  | var HMaterTexture = list[i]["材质"].ToString(); | 
|---|
|  |  |  | var HProductNum = list[i]["成品编号"].ToString(); | 
|---|
|  |  |  | var HVerNum = list[i]["版本"].ToString(); | 
|---|
|  |  |  | var HMainPrice = list[i]["工序工价"].ToString(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (hnumber != list[i]["产品代码"].ToString()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //获取相同主表的子表的添加次数 HEntryID | 
|---|
|  |  |  | num[0] = 1; | 
|---|
|  |  |  | hnumber = list[i]["产品代码"].ToString(); | 
|---|
|  |  |  | HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);//获得一个新的单据号 | 
|---|
|  |  |  | HInterID = DBUtility.ClsPub.CreateBillID_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo);//获得一个新的id | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //添加主表数据 | 
|---|
|  |  |  | oCN.RunProc("insert into Gy_RoutingBillMain(HInterID, HBillNo, HYear, HPeriod, HBillType, HDate, HBillStatus, " + | 
|---|
|  |  |  | "HMaker, HMakeDate,HMaterNumber, HMaterID, Hunitid, HUnitNumber, HName," + | 
|---|
|  |  |  | "HPicNumVer, HPicNumAssemble, HMaterTexture, HProductNum, HVerNum, HRoutingGroupID, HStandard, HRemark,HMainPrice" + | 
|---|
|  |  |  | ",HOrgID)values" + | 
|---|
|  |  |  | $"({HInterID}, '{HBillNo}', {omdelMian.HYear}, {omdelMian.HPeriod}, '{BillType}', GETDATE(), 1" + | 
|---|
|  |  |  | $", '{user}', GETDATE(), '{HMaterNumber}', {HMaterID}, {Hunitid}, '{HUnitNumber}', '{HName}'," + | 
|---|
|  |  |  | $" '{HPicNumVer}', '{HPicNumAssemble}', '{HMaterTexture}', '{HProductNum}', '{HVerNum}', 0, 1, '',{(HMainPrice==""?"0":HMainPrice)}" + | 
|---|
|  |  |  | $",{omdelMian.HOrgID})"); | 
|---|
|  |  |  | //获取主表添加的次数 | 
|---|
|  |  |  | num[1]++; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取供应商 | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_Gy_SupplierList Where 供应商代码='" + list[i]["供应商代码"].ToString()+"'", "h_v_Gy_SupplierList"); | 
|---|
|  |  |  | var HSupID = "0"; | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count > 0) | 
|---|
|  |  |  | HSupID = ds.Tables[0].Rows[0]["HItemID"].ToString(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取工序 | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from Gy_Process Where HNumber='" + list[i]["工序代码"].ToString() + "'", "Gy_Process"); | 
|---|
|  |  |  | var HProcID = "0"; | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count > 0) | 
|---|
|  |  |  | HProcID = ds.Tables[0].Rows[0]["HItemID"].ToString(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取工作中心 | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from Gy_WorkCenter Where HNumber='" + list[i]["工作中心代码"].ToString() + "'", "Gy_WorkCenter"); | 
|---|
|  |  |  | var HCenterID = "0"; | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count > 0) | 
|---|
|  |  |  | HCenterID = ds.Tables[0].Rows[0]["HItemID"].ToString(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var HProcNo = list[i]["工序序号"].ToString(); | 
|---|
|  |  |  | var HTimeUnit = list[i]["时间单位"].ToString(); | 
|---|
|  |  |  | var hworkqty = list[i]["加工数量"].ToString(); | 
|---|
|  |  |  | var HFixPrice = list[i]["班产定额"].ToString(); | 
|---|
|  |  |  | var HBadPrice = list[i]["不合格单价"].ToString(); | 
|---|
|  |  |  | var HWasterPrice = list[i]["报废单价"].ToString(); | 
|---|
|  |  |  | var HBeginFixQty = list[i]["本道固定开工天数"].ToString(); | 
|---|
|  |  |  | var HBeginDayQty = list[i]["本道开工余量"].ToString(); | 
|---|
|  |  |  | var HFixWorkDays = list[i]["上道等待天数"].ToString(); | 
|---|
|  |  |  | var HTrunWorkDays = list[i]["上道循环周期"].ToString(); | 
|---|
|  |  |  | var HAutoTrunFlag = list[i]["自动转移"].ToString(); | 
|---|
|  |  |  | var HSupFlag = list[i]["外协标记"].ToString(); | 
|---|
|  |  |  | var HTechnologyParameter = list[i]["工艺参数"].ToString(); | 
|---|
|  |  |  | var HPicNum = list[i]["图纸编号"].ToString(); | 
|---|
|  |  |  | var HProcCheckNote = list[i]["本工序确认记录"].ToString(); | 
|---|
|  |  |  | var hpassrate = list[i]["良率"].ToString(); | 
|---|
|  |  |  | var hremark = list[i]["备注"].ToString(); | 
|---|
|  |  |  | var HMouldNo = list[i]["模具编号"].ToString(); | 
|---|
|  |  |  | var HProcWorkNum = list[i]["程序号"].ToString(); | 
|---|
|  |  |  | //物料分类 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | oCN.RunProc("Insert into Gy_RoutingBillSub (HInterID,HEntryID,HSupID,HProcID,HCenterID,HProcNO,HTimeUnit" + | 
|---|
|  |  |  | ", hworkqty, HFixPrice, HBadPrice, HWasterPrice, HBeginFixQty, HBeginDayQty, HFixWorkDays" + | 
|---|
|  |  |  | ", HTrunWorkDays, HAutoTrunFlag, HSupFlag, HTechnologyParameter, HPicNum, HProcCheckNote" + | 
|---|
|  |  |  | ", hpassrate, hremark, HMouldNo, HProcWorkNum, HReadyTime, HQueueTime, HMoveTime, HUnitTime)values" + | 
|---|
|  |  |  | $"({HInterID}, {num[0]}, {HSupID}, {HProcID},{HCenterID}, '{HProcNo}', '{HTimeUnit}'" + | 
|---|
|  |  |  | $", {hworkqty}, {(HFixPrice==""?"0": HFixPrice)}, {(HBadPrice == "" ? "0": HBadPrice)}, {(HWasterPrice == "" ? "0": HWasterPrice)}, {(HBeginFixQty == "" ? "0": HBeginFixQty)}, {(HBeginDayQty == "" ? "0": HBeginDayQty)}, {(HFixWorkDays == "" ? "0": HFixWorkDays)}" + | 
|---|
|  |  |  | $", {(HTrunWorkDays == "" ? "0": HTrunWorkDays)},{(HAutoTrunFlag == "True" ? "1": "0")},{(HSupFlag == "True" ? "1" : "0")}, '{HTechnologyParameter}', '{HPicNum}', '{HProcCheckNote}'" + | 
|---|
|  |  |  | $", {hpassrate}, '{hremark}', '{HMouldNo}', '{HProcWorkNum}', 0, 0, 0, 0)"); | 
|---|
|  |  |  | //自增次数 | 
|---|
|  |  |  | num[0]++; | 
|---|
|  |  |  | var HInterID = DBUtility.ClsPub.CreateBillID_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo);//获得一个新的id | 
|---|
|  |  |  | oCN.RunProc($"exec Gy_RoutingBill_Excel '{ds.Tables[0].Rows[i]["产品代码"].ToString()}',{HInterID},'{HBillNo}','{user}',{omdelMian.HOrgID},{omdelMian.HTProcessFlag} "); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "导入完成,共" + num[1] + "个工艺路线"; | 
|---|
|  |  |  | objJsonResult.Message = "导入完成,共" + ds.Tables[0].Rows.Count + "个工艺路线"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|