| | |
| | | } |
| | | } |
| | | |
| | | //删除临时表数据 |
| | | 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() + "')"); |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = error; |
| | |
| | | //表头字段 |
| | | 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 产品代码 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()) |
| | | { |
| | | dic.Add(itm.Name, itm.Value.ToString()); |
| | | } |
| | | 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 HName='" + 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]++; |
| | | if(omdelMian.HTProcessFlag == 1 ) |
| | | { |
| | | if ((i == list.Count - 1) || (list[i]["产品代码"].ToString() != list[i + 1]["产品代码"].ToString())) |
| | | { |
| | | ds = oCN.RunProcReturn("select * from Gy_Process Where HTProcessFlag = 1", "Gy_Process"); |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | HProcID = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | HProcNo = ds.Tables[0].Rows[0]["HSno"].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 HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);//获得一个新的单据号 |
| | | 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; |
| | | } |