|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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;//日期 | 
|---|
|  |  |  | 
|---|
|  |  |  | string HProductNum = mainList[0].HProductNum;//成品编号 | 
|---|
|  |  |  | string HVerNum = mainList[0].HVerNum;//版本 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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 && ds.Tables[0].Rows.Count == 0)//新增 | 
|---|
|  |  |  | if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//新增 | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //主表 | 
|---|
|  |  |  | oCN.RunProc("Insert Into Gy_RoutingBillMain   " + | 
|---|
|  |  |  | 
|---|
|  |  |  | ",HProductNum='" + HProductNum + "',HVerNum='" + HVerNum + "' where HInterID='" + HInterID + "'"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //删除子表 | 
|---|
|  |  |  | oCN.RunProc("delete from Gy_RoutingBillSub where HInterID='" + HInterID+"'"); | 
|---|
|  |  |  | oCN.RunProc("delete from Gy_RoutingBillSub where HInterID='" + HInterID + "' and HProcNo!='9999'"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //保存子表 | 
|---|
|  |  |  | objJsonResult = AddBillSub(msg3, HInterID); | 
|---|
|  |  |  | 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) | 
|---|
|  |  |  | 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 + "," + i + "," + oSub.HProcID.ToString() + ",'" + i + "'," + 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); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | , 本工序确认记录, 备注, 图号版本, 总装图号, 材质, 成品编号, 版本 | 
|---|
|  |  |  | , 模具编号, 程序号, 班产定额, 工艺路线名称, 时间单位,工艺路线代码)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() == "" ? "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() + "')"); | 
|---|
|  |  |  | 
|---|
|  |  |  | omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<Gy_RoutingBill_temporary>(msg2); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select  distinct 产品代码,工艺路线代码 from  diyipi ", "diyipi"); | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select  distinct 产品代码,isnull(工艺路线代码,'') 工艺路线代码 from  diyipi ", "diyipi"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (int i = 0; i < ds.Tables[0].Rows.Count; i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var HBillNo = ds.Tables[0].Rows[i]["工艺路线代码"].ToString();//获得一个新的单据号 | 
|---|
|  |  |  | if (HBillNo == "") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 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"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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} "); | 
|---|
|  |  |  | } | 
|---|