|  |  | 
 |  |  |  | 
 |  |  |         private json objJsonResult = new json(); | 
 |  |  |         Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); | 
 |  |  |  | 
 |  |  |         public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill(); | 
 |  |  |         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
 |  |  |         DataSet ds; | 
 |  |  |  | 
 |  |  | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         #endregion | 
 |  |  |  | 
 |  |  |         #region 斯莫尔 末道工序汇报列表  汇报 入库 | 
 |  |  |         /// <summary> | 
 |  |  | 
 |  |  |                 string OrganizationNUM = oCN.RunProcReturn("select HNumber from Xt_ORGANIZATIONS where HItemID=" + OrganizationID, "Xt_ORGANIZATIONS").Tables[0].Rows[0]["HNumber"].ToString(); | 
 |  |  |                 //根据工序汇报单主ID获取工序汇报入库单的数据 | 
 |  |  |                 DataSet ds = oCN.RunProcReturn("select * from h_v_MES_StationOutBillList_LastProc where HInterID=" + InterID, "h_v_MES_StationOutBillList_LastProc"); | 
 |  |  |                 if (ds.Tables[0].Rows.Count <= 0) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "生成生产汇报单过程中没有查询到出站单"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |                 DataRow dr = ds.Tables[0].Rows[0]; | 
 |  |  |                  | 
 |  |  |  | 
 |  |  |                 //保存 | 
 |  |  |                 oCN.BeginTran(); | 
 |  |  |                 DataSet DsTable = oCN.RunProcReturn($"select * from Sc_ICMOReportBillMain where HBillNo='{HBillNo}'"  , "Sc_ICMOReportBillMain"); | 
 |  |  |                 DataSet DsTable = oCN.RunProcReturn($"select * from Sc_ICMOReportBillMain where HBillNo='{HBillNo}'", "Sc_ICMOReportBillMain"); | 
 |  |  |                 if (DsTable.Tables[0].Rows.Count > 0) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |                     //生产汇报单主表 | 
 |  |  |                     oCN.RunProc("Insert Into Sc_ICMOReportBillMain   " + | 
 |  |  |                 "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate,HBillStatus,HChecker,HCheckDate" + | 
 |  |  |                 ",HYear,HPeriod,HRemark,HEmpID,HEmpNumber" + | 
 |  |  |                 ",HGroupID,HDeptID,HDeptNumber" + | 
 |  |  |                 ",HMainSourceBillNo,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillType" + | 
 |  |  |                 ") " + | 
 |  |  |                 " values('3711','3711'," + HInterID.ToString() + ",'" + BillNo + "',getdate(),'" + user + "',getdate(),2,'" + user + "',getdate()" + | 
 |  |  |                 ",DATENAME(YEAR,GETDATE()),0,'','" + dr["HEmpID"].ToString() + "','" + dr["操作员代码"].ToString() + | 
 |  |  |                 "','" + dr["HGroupID"].ToString() + "',0,''" + | 
 |  |  |                 ",'" + BillNo.ToString() + "'," + InterID.ToString() + ", 0,'3791'" + | 
 |  |  |                 ") "); | 
 |  |  |                 //生产汇报单主表 | 
 |  |  |                 oCN.RunProc("Insert Into Sc_ICMOReportBillMain   " + | 
 |  |  |             "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate,HBillStatus,HChecker,HCheckDate" + | 
 |  |  |             ",HYear,HPeriod,HRemark,HEmpID,HEmpNumber" + | 
 |  |  |             ",HGroupID,HDeptID,HDeptNumber" + | 
 |  |  |             ",HMainSourceBillNo,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillType" + | 
 |  |  |             ") " + | 
 |  |  |             " values('3711','3711'," + HInterID.ToString() + ",'" + BillNo + "',getdate(),'" + user + "',getdate(),2,'" + user + "',getdate()" + | 
 |  |  |             ",DATENAME(YEAR,GETDATE()),0,'','" + dr["HEmpID"].ToString() + "','" + dr["操作员代码"].ToString() + | 
 |  |  |             "','" + dr["HGroupID"].ToString() + "',0,''" + | 
 |  |  |             ",'" + BillNo.ToString() + "'," + InterID.ToString() + ", 0,'3791'" + | 
 |  |  |             ") "); | 
 |  |  |                 //生产汇报单子表 | 
 |  |  |                 oCN.RunProc("Insert into Sc_ICMOReportBillSub " + | 
 |  |  |                       " (HInterID,HEntryID,HMaterID,HMaterNumber" + | 
 |  |  | 
 |  |  |                 model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //单据日期1 | 
 |  |  |                 model.Add("FHZYMESFLAG", "是");//  是否为MES同步 | 
 |  |  |                 model.Add("FBillNo", BillNo); | 
 |  |  |                  | 
 |  |  |  | 
 |  |  |                 JArray Fentity = new JArray(); | 
 |  |  |  | 
 |  |  |                 foreach (DataRow item in ds.Tables[0].Rows) | 
 |  |  | 
 |  |  |                     //["IsAutoSubmitAndAudit"] = true,//自动调用提交和审核功能 | 
 |  |  |                     ["Model"] = model | 
 |  |  |                 }; | 
 |  |  |                  | 
 |  |  |  | 
 |  |  |                 string result = InvokeHelper.Save("PRD_MORPT", JsonConvert.SerializeObject(jsonRoot));//保存 | 
 |  |  |                 //判断保存是否成功 | 
 |  |  |                 if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") | 
 |  |  | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 oCN.RunProc("update Sc_StationOutBillMain set HRelationQty=1 where  HBillNo='" + BillNo+"'"); | 
 |  |  |                 oCN.RunProc("update Sc_StationOutBillMain set HRelationQty=1 where  HBillNo='" + BillNo + "'"); | 
 |  |  |  | 
 |  |  |                 oCN.Commit(); | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  | 
 |  |  |                 //DataRow dr = ds.Tables[0].Rows[0]; | 
 |  |  |  | 
 |  |  |                 //判断入库的合格数量是否为0 | 
 |  |  |                 var DTable = oCN.RunProcReturn("select * from  Sc_StationOutBillMain where HBillNo='"+ BillNo + "' ", "Sc_StationOutBillMain").Tables[0]; | 
 |  |  |                 var DTable = oCN.RunProcReturn("select * from  Sc_StationOutBillMain where HBillNo='" + BillNo + "' ", "Sc_StationOutBillMain").Tables[0]; | 
 |  |  |  | 
 |  |  |                 if (double.Parse(DTable.Rows[0]["HQty"].ToString()) == 0) | 
 |  |  |                 { | 
 |  |  | 
 |  |  |                 // | 
 |  |  |                 //DataSet ds1 = oCN.RunProcReturn("select * from  h_v_TOERPProcduct_LastProc where HLastProc = '是' and  hbillno='" + BillNo.ToString() + "'", "h_v_TOERPProcduct_LastProc"); | 
 |  |  |                 DataSet ds1 = oCN.RunProcReturn("exec h_p_TOERPProcduct_LastProc '" + BillNo + "'", "h_p_TOERPProcduct_LastProc"); | 
 |  |  |  | 
 |  |  |                 if (ds1 == null || ds1.Tables[0].Rows.Count == 0) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "未找到对应的本地或金蝶云生产汇报单记录;1.未查询到对应的生产汇报单;2.请确保当前工序是末道工序3.汇报单对应的入库数量已满 请在金蝶云查看入库记录!"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 DataRow dr1 = ds1.Tables[0].Rows[0]; | 
 |  |  |                 if (ds1.Tables[0].Rows.Count <= 0) | 
 |  |  |                 if (double.Parse(dr1[0].ToString()) <= 0) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                 string sErr = ""; | 
 |  |  |                 if (oSystemParameter.ShowBill(ref sErr)) | 
 |  |  |                 { | 
 |  |  |                     if (oSystemParameter.omodel.WMS_CampanyName == "瑞与祺") | 
 |  |  |                     { | 
 |  |  |  | 
 |  |  |                         //判断金蝶云是否已经有入库的数据 | 
 |  |  |                         ds = oCN.RunProcReturn($@"select * from AIS20220308151944..T_PRD_INSTOCK where FBILLNO='{BillNo}'", "T_PRD_INSTOCK"); | 
 |  |  |  | 
 |  |  |                         if (ds.Tables[0].Rows.Count > 0) | 
 |  |  |                         { | 
 |  |  |                             objJsonResult.code = "0"; | 
 |  |  |                             objJsonResult.count = 0; | 
 |  |  |                             objJsonResult.Message = "当前出站单号已入库,请不要重新入库!"; | 
 |  |  |                             objJsonResult.data = null; | 
 |  |  |                             return objJsonResult; | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                         //判断金蝶云生产汇报单 数量 是否 大于 末道出站数量 | 
 |  |  |                         ds = oCN.RunProcReturn($@"select sum(FFinishQty)-sum(FSTOCKINQUASELQTY)-(select HQty from Sc_StationOutBillMain where HBillNo='{BillNo}')  | 
 |  |  |                         from  AIS20220308151944..T_PRD_MORPT rpt3  | 
 |  |  |                         left join AIS20220308151944..T_PRD_MORPTENTRY  rpt2 on rpt3.FID = rpt2.FID | 
 |  |  |                         left join AIS20220308151944..T_PRD_MORPTENTRY_A  rpt1 on rpt2.FID = rpt1.FID | 
 |  |  |                         where F_bsv_Text=(select HProcExchBillNo from Sc_StationOutBillMain where HBillNo='{BillNo}')", "SumCount"); | 
 |  |  |  | 
 |  |  |                         if (double.Parse(ds.Tables[0].Rows[0][0].ToString()) < 0) | 
 |  |  |                         { | 
 |  |  |                             objJsonResult.code = "0"; | 
 |  |  |                             objJsonResult.count = 0; | 
 |  |  |                             objJsonResult.Message = "金蝶云汇报数量小于本地出站数量!"; | 
 |  |  |                             objJsonResult.data = null; | 
 |  |  |                             return objJsonResult; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                 JObject model = new JObject(); | 
 |  |  |                 model.Add("FBillType", new JObject() { ["FNumber"] = "SCRKD01_SYS" }); //单据类型 | 
 |  |  | 
 |  |  |                     FentityModel.Add("FBaseRealQty", item["数量"].ToString());// | 
 |  |  |                     FentityModel.Add("FOwnerTypeId", "BD_OwnerOrg");// | 
 |  |  |                     FentityModel.Add("FOwnerId", new JObject() { ["FNumber"] = item["HPrdOrgNumber"].ToString() });// | 
 |  |  |                     string sErr = ""; | 
 |  |  |  | 
 |  |  |                     if (oSystemParameter.ShowBill(ref sErr)) | 
 |  |  |                     { | 
 |  |  |                         if (oSystemParameter.omodel.WMS_CampanyName == "瑞与祺") | 
 |  |  | 
 |  |  |                     FentityModel.Add("F_bsv_Base1", new JObject() { ["FNumber"] = item["HBZBS"].ToString() });// | 
 |  |  |                     FentityModel.Add("F_BSV_TEXT", item["HLZKH"].ToString());//   | 
 |  |  |                     FentityModel.Add("F_BSV_TEXT1", item["HWYID"].ToString());// | 
 |  |  |                                                                                //批号 | 
 |  |  |                                                                                //FFLOWID FFLOWLINEID FRULEID FSTABLENAME | 
 |  |  |                                                                                //f6e6eec3 - 5267 - 4f02 - 8593 - b633da508a72    3   PRD_MO2MORPT T_PRD_MOENTRY | 
 |  |  |                                                                                //业务流程图:FEntity_Link_FFlowId | 
 |  |  |                                                                                //推进路线:FEntity_Link_FFlowLineId | 
 |  |  |                                                                                //转换规则:FEntity_Link_FRuleId | 
 |  |  |                                                                                //源单表内码:FEntity_Link_FSTableId | 
 |  |  |                                                                                //源单表:FEntity_Link_FSTableName | 
 |  |  |                                                                                //源单内码:FEntity_Link_FSBillId | 
 |  |  |                                                                                //源单分录内码:FEntity_Link_FSId | 
 |  |  |                                                                                //原始携带量:FEntity_Link_FBaseQuaQtyOld | 
 |  |  |                                                                                //修改携带量:FEntity_Link_FBaseQuaQty | 
 |  |  |                                                                               //批号 | 
 |  |  |                                                                               //FFLOWID FFLOWLINEID FRULEID FSTABLENAME | 
 |  |  |                                                                               //f6e6eec3 - 5267 - 4f02 - 8593 - b633da508a72    3   PRD_MO2MORPT T_PRD_MOENTRY | 
 |  |  |                                                                               //业务流程图:FEntity_Link_FFlowId | 
 |  |  |                                                                               //推进路线:FEntity_Link_FFlowLineId | 
 |  |  |                                                                               //转换规则:FEntity_Link_FRuleId | 
 |  |  |                                                                               //源单表内码:FEntity_Link_FSTableId | 
 |  |  |                                                                               //源单表:FEntity_Link_FSTableName | 
 |  |  |                                                                               //源单内码:FEntity_Link_FSBillId | 
 |  |  |                                                                               //源单分录内码:FEntity_Link_FSId | 
 |  |  |                                                                               //原始携带量:FEntity_Link_FBaseQuaQtyOld | 
 |  |  |                                                                               //修改携带量:FEntity_Link_FBaseQuaQty | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | 
 |  |  |                     JObject FentityModel2 = new JObject(); | 
 |  |  |                     FentityModel2.Add("FEntity_Link_FFlowId", "f6e6eec3-5267-4f02-8593-b633da508a72"); | 
 |  |  |                     FentityModel2.Add("FEntity_Link_FFlowLineId", "5"); | 
 |  |  |                     FentityModel2.Add("FEntity_Link_FRuleId", "PRD_MORPT2INSTOCK");  | 
 |  |  |                     FentityModel2.Add("FEntity_Link_FRuleId", "PRD_MORPT2INSTOCK"); | 
 |  |  |                     FentityModel2.Add("FEntity_Link_FSTableName", "T_PRD_MORPTENTRY"); | 
 |  |  |                     FentityModel2.Add("FEntity_Link_FSTableId", "0"); | 
 |  |  |                     FentityModel2.Add("FEntity_Link_FSBillId", item["HSourceInterID"].ToString()); | 
 |  |  | 
 |  |  |                 //DataRow dr = ds.Tables[0].Rows[0]; | 
 |  |  |  | 
 |  |  |                 //判断本次报废总数量是否为0 | 
 |  |  |                 var DTable = oCN.RunProcReturn("select sum(HWasterQty) HWasterQty from  Sc_StationOutBillMain where  HProcExchBillNo='"+ BillNo + "' and HBFFlag=0 ", "Sc_StationOutBillMain").Tables[0]; | 
 |  |  |                 var DTable = oCN.RunProcReturn("select isnull(sum(HWasterQty),0) HWasterQty from  Sc_StationOutBillMain where  HProcExchBillNo='" + BillNo + "' and HBFFlag=0 ", "Sc_StationOutBillMain").Tables[0]; | 
 |  |  |  | 
 |  |  |                 if (double.Parse(DTable.Rows[0]["HWasterQty"].ToString()) == 0) | 
 |  |  |                 { | 
 |  |  | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                  //oCN.RunProc("update Sc_StationOutBillMain set HRelationQty=1 where  HBillNo='" + BillNo + "'"); | 
 |  |  |                 //oCN.RunProc("update Sc_StationOutBillMain set HRelationQty=1 where  HBillNo='" + BillNo + "'"); | 
 |  |  |  | 
 |  |  |                 oCN.Commit(); | 
 |  |  |                 oCN.RunProc("update  sc_stationoutbillmain set HBFFlag =1 where HProcExchBillNo = '" + BillNo + "'"); | 
 |  |  | 
 |  |  |         /// <returns></returns> | 
 |  |  |         [Route("QCStockInCheckBill/set_SaveQCStockInCheckBill_Json")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object set_SaveQCStockInCheckBill_Json(string HZJOrgNumber, string HMaterNumber, string HUnitNumber,  | 
 |  |  |         public object set_SaveQCStockInCheckBill_Json(string HZJOrgNumber, string HMaterNumber, string HUnitNumber, | 
 |  |  |             double HCheckQty, double HRightQty, double HBadQty, | 
 |  |  |             string HCheckResult, string HSupNumber, string HWHNumber, | 
 |  |  |             string HUseResult, Int64 HSeQ, Int64 HSourceInterID,  | 
 |  |  |             string HCheckResult, string HSupNumber, | 
 |  |  |             string HUseResult, Int64 HSeQ, Int64 HSourceInterID, | 
 |  |  |             Int64 HSourceEntryID, string HSourceBillNo, string user, | 
 |  |  |             Int64 HWHID, Int64 HSPID, Int64 HSupID, Int64 HKeeperID,  | 
 |  |  |             Int64 HWHID, Int64 HSPID, Int64 HSupID, Int64 HKeeperID, | 
 |  |  |             Int64 HMaterID, string HSourceBillType, Int64 HSLInterID, | 
 |  |  |             Int64 HSLEntryID, string HSLBillNo, Int64 HSLSeQ, string HBillNo, Int64 HInterID) | 
 |  |  |             Int64 HSLEntryID, string HSLBillNo, Int64 HSLSeQ, string HBillNo, Int64 HInterID, string HBatchNo) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  | 
 |  |  |                 DataSet ds1 = oCN.RunProcReturn("select   * from MES_AccessoriesList  where  HSourceBillNo = '" + HBillNo + "'", "MES_AccessoriesList"); | 
 |  |  |                 string HFileName = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HFileName"]); | 
 |  |  |                 string HFilePath = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HFilePath"]); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                 string path = HFilePath; | 
 |  |  |                 FileInfo fi = new FileInfo(path); | 
 |  |  | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |                  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                 JObject model = new JObject(); | 
 |  |  |                 model.Add("FBillTypeID", new JObject() { ["Fnumber"] = "JYD001_SYS" }); //单据类型 来料检验单JYD001_SYS | 
 |  |  |                 model.Add("FBusinessType", "1"); //业务类型 | 
 |  |  |                 model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //单据日期 | 
 |  |  |                 model.Add("FSourceOrgId", new JObject() { ["Fnumber"] = HZJOrgNumber.ToString() }); //来源组织 | 
 |  |  |                 model.Add("FInspectOrgId", new JObject() { ["Fnumber"] = HZJOrgNumber.ToString() }); //质检组织 | 
 |  |  |                 model.Add("FSourceOrgId", new JObject() { ["Fnumber"] = HZJOrgNumber.ToString() }); //来源组织 | 
 |  |  |                 model.Add("FISSYNCED", "false");//  是否已同步 | 
 |  |  |                 model.Add("F_PGKJ_Date", DateTime.Now.ToString("yyyy-MM-dd"));//  报检日期 | 
 |  |  |                 model.Add("FBillNo", HBillNo); | 
 |  |  |  | 
 |  |  |                 JArray Fentity = new JArray(); | 
 |  |  |                     JObject FentityModel = new JObject(); | 
 |  |  |                     FentityModel.Add("FMaterialId", new JObject() { ["Fnumber"] = HMaterNumber.ToString() });//  物料内码  | 
 |  |  |                     FentityModel.Add("FUnitID", new JObject() { ["Fnumber"] = HUnitNumber.ToString() });//计量单位内码 | 
 |  |  |                     FentityModel.Add("FInspectQty", HCheckQty.ToString());//  检验数量  | 
 |  |  |                     FentityModel.Add("FQualifiedQty", HRightQty.ToString());//  合格数量  | 
 |  |  |                     FentityModel.Add("FUnqualifiedQty", HBadQty.ToString());//  不合格数量 | 
 |  |  |                     FentityModel.Add("FInspectResult", HCheckResult.ToString());//  检验结果 | 
 |  |  |                     FentityModel.Add("FQCStatus", "1");//  质检状态  | 
 |  |  |                     FentityModel.Add("FIsRelated", false);//  不良品关联标志 | 
 |  |  |                     FentityModel.Add("FSrcBillType0", "PUR_ReceiveBill");//  源单类型 | 
 |  |  |                     FentityModel.Add("FBaseUnitId", new JObject() { ["Fnumber"] = HUnitNumber.ToString() });//基本单位 | 
 |  |  |                     FentityModel.Add("FBaseInspectQty", HCheckQty.ToString());//基本单位检验数量 | 
 |  |  |                     FentityModel.Add("FSupplierId", new JObject() { ["Fnumber"] = HSupNumber.ToString() }); //  供应商 | 
 |  |  |                     //FentityModel.Add("FStockId", new JObject() { ["Fnumber"] = HWHNumber.ToString() }); // 仓库 | 
 |  |  |                     FentityModel.Add("FInspectTimes","1"); // 检验次数  | 
 |  |  |                     FentityModel.Add("FTimeUnit","24");//时间单位 | 
 |  |  |                     FentityModel.Add("FSAMPLEDAMAGEBEARER","2");//样本破坏承担方 | 
 |  |  |                     FentityModel.Add("FISFIRSTINSPECT", false);//首检 | 
 |  |  |                     FentityModel.Add("FBaseQualifiedQty", HRightQty.ToString());//基本单位合格数 | 
 |  |  |                 JObject FentityModel = new JObject(); | 
 |  |  |                 FentityModel.Add("FMaterialId", new JObject() { ["Fnumber"] = HMaterNumber.ToString() });//  物料内码  | 
 |  |  |                 FentityModel.Add("FUnitID", new JObject() { ["Fnumber"] = HUnitNumber.ToString() });//计量单位内码 | 
 |  |  |                 FentityModel.Add("FInspectQty", HCheckQty.ToString());//  检验数量  | 
 |  |  |                 FentityModel.Add("FQualifiedQty", HRightQty.ToString());//  合格数量  | 
 |  |  |                 FentityModel.Add("FUnqualifiedQty", HBadQty.ToString());//  不合格数量 | 
 |  |  |                 FentityModel.Add("FInspectResult", HCheckResult.ToString());//  检验结果 | 
 |  |  |                 FentityModel.Add("FQCStatus", "1");//  质检状态  | 
 |  |  |                 FentityModel.Add("FIsRelated", false);//  不良品关联标志 | 
 |  |  |                 FentityModel.Add("FSrcBillType0", "PUR_ReceiveBill");//  源单类型 | 
 |  |  |                 FentityModel.Add("FBaseUnitId", new JObject() { ["Fnumber"] = HUnitNumber.ToString() });//基本单位 | 
 |  |  |                 FentityModel.Add("FBaseInspectQty", HCheckQty.ToString());//基本单位检验数量 | 
 |  |  |                 FentityModel.Add("FSupplierId", new JObject() { ["Fnumber"] = HSupNumber.ToString() }); //  供应商 | 
 |  |  |                                                                                                         //FentityModel.Add("FStockId", new JObject() { ["Fnumber"] = HWHNumber.ToString() }); // 仓库 | 
 |  |  |                 FentityModel.Add("FInspectTimes", "1"); // 检验次数  | 
 |  |  |                 FentityModel.Add("FTimeUnit", "24");//时间单位 | 
 |  |  |                 FentityModel.Add("FSAMPLEDAMAGEBEARER", "2");//样本破坏承担方 | 
 |  |  |                 FentityModel.Add("FISFIRSTINSPECT", false);//首检 | 
 |  |  |                 FentityModel.Add("FBaseQualifiedQty", HRightQty.ToString());//基本单位合格数 | 
 |  |  |                 FentityModel.Add("FBaseAcceptQty", HRightQty.ToString());//基本单位接收数 | 
 |  |  |                 FentityModel.Add("FCurrency", new JObject() { ["Fnumber"] = "PRE001" });//币别 | 
 |  |  |                     FentityModel.Add("FIsSplitRow ", false);// 是否拆分行 | 
 |  |  |                 FentityModel.Add("FIsSplitRow ", false);// 是否拆分行 | 
 |  |  |                 FentityModel.Add("FLot", new JObject() { ["Fnumber"] = HBatchNo.ToString() });//批号 | 
 |  |  |  | 
 |  |  |                     JArray Fentity2 = new JArray(); | 
 |  |  |                     JObject FentityModel2 = new JObject(); | 
 |  |  |                     FentityModel2.Add("FPolicyMaterialId", new JObject() { ["Fnumber"] = HMaterNumber.ToString() });//  物料内码  | 
 |  |  |                     FentityModel2.Add("FPolicyStatus", "1");  //状态 | 
 |  |  |                     FentityModel2.Add("FPolicyQty", HRightQty.ToString());    //数量 | 
 |  |  |                     FentityModel2.Add("FBasePolicyQty", HRightQty.ToString()); //基本单位数量 | 
 |  |  |                     FentityModel2.Add("FUsePolicy", HUseResult.ToString());   //使用决策 | 
 |  |  |                     FentityModel2.Add("FIsCheck", false);   //是否抽检 | 
 |  |  |                     FentityModel2.Add("FIsDefectProcess", false);  //不良处理 | 
 |  |  |                     FentityModel2.Add("FCanSale", false);   //可销售 | 
 |  |  |                     FentityModel2.Add("FIsMRBReview", false);   //MRP评审 | 
 |  |  |                     FentityModel2.Add("FIsReturn", true);   //判退 | 
 |  |  |                     FentityModel2.Add("FIsRelatedDefect", false);   //不良品关联标志 | 
 |  |  |                     Fentity2.Add(FentityModel2); | 
 |  |  |                     FentityModel.Add("FPolicyDetail", Fentity2); | 
 |  |  |                 JArray Fentity2 = new JArray(); | 
 |  |  |                 JObject FentityModel2 = new JObject(); | 
 |  |  |                 FentityModel2.Add("FPolicyMaterialId", new JObject() { ["Fnumber"] = HMaterNumber.ToString() });//  物料内码  | 
 |  |  |                 FentityModel2.Add("FPolicyStatus", "1");  //状态 | 
 |  |  |                 FentityModel2.Add("FPolicyQty", HRightQty.ToString());    //数量 | 
 |  |  |                 FentityModel2.Add("FBasePolicyQty", HRightQty.ToString()); //基本单位数量 | 
 |  |  |                 FentityModel2.Add("FUsePolicy", HUseResult.ToString());   //使用决策 | 
 |  |  |                 FentityModel2.Add("FIsCheck", false);   //是否抽检 | 
 |  |  |                 FentityModel2.Add("FIsDefectProcess", false);  //不良处理 | 
 |  |  |                 FentityModel2.Add("FCanSale", false);   //可销售 | 
 |  |  |                 FentityModel2.Add("FIsMRBReview", false);   //MRP评审 | 
 |  |  |                 FentityModel2.Add("FIsReturn", true);   //判退 | 
 |  |  |                 FentityModel2.Add("FIsRelatedDefect", false);   //不良品关联标志 | 
 |  |  |                 Fentity2.Add(FentityModel2); | 
 |  |  |                 FentityModel.Add("FPolicyDetail", Fentity2); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | 
 |  |  |                 FentityModel3.Add("FSrcBillType", "PUR_ReceiveBill");   //源单类型 | 
 |  |  |                 FentityModel3.Add("FSrcBillNo", HSLBillNo.ToString());    //收料通知单单号 | 
 |  |  |                 FentityModel3.Add("FSrcInterId", HSLInterID.ToString());      //收料通知单主ID | 
 |  |  |                 FentityModel3.Add("FSrcEntryId",HSLEntryID.ToString());    //收料通知单子ID | 
 |  |  |                 FentityModel3.Add("FSrcEntryId", HSLEntryID.ToString());    //收料通知单子ID | 
 |  |  |                 FentityModel3.Add("FSrcEntrySeq", HSLSeQ.ToString());    //源单行号 | 
 |  |  |                 FentityModel3.Add("FOrderType", new JObject() { ["FID"] = "PUR_PurchaseOrder" });  //  订单类型 | 
 |  |  |                 FentityModel3.Add("FOrderBillNo", HSourceBillNo.ToString());   //订单单号 | 
 |  |  | 
 |  |  |                     Ids = fID, | 
 |  |  |                 }; | 
 |  |  |  | 
 |  |  |                 K3CloudApiClient client = new K3CloudApiClient("http://192.168.80.90/k3cloud/"); | 
 |  |  |                 K3CloudApiClient client = new K3CloudApiClient("http://47.96.97.237/k3cloud"); | 
 |  |  |                 //        K3CloudApiClient client = new K3CloudApiClient("http://192.168.80.90/k3cloud/"); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | 
 |  |  |                 result2 = InvokeHelper.Audit("QM_InspectBill", JsonConvert.SerializeObject(json));//提交 | 
 |  |  |                 if (JObject.Parse(result1)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") | 
 |  |  |                 { | 
 |  |  |                     string jsonStr = "{" + | 
 |  |  |                         " \"FileName\":\"" + HFileName + "\"," + | 
 |  |  |                             " \"FormId\":\"QM_InspectBill\"," + | 
 |  |  |                             " \"IsLast\":\"true\"," + | 
 |  |  |                             " \"InterId\":\"" + HInterID + "\"," + | 
 |  |  |                             " \"BillNO\":\"" + HBillNo + "\"," + | 
 |  |  |                             " \"AliasFileName\":\"test\"," + | 
 |  |  |                             " \"SendByte\":\"" + a + "\"," + | 
 |  |  |                         "}"; | 
 |  |  |  | 
 |  |  |                     var ret = client.AttachmentUpload(jsonStr); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                     oCN.RollBack(); | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = $"来料检验单号:{fBillNo},提交失败" + result; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |                 else | 
 |  |  |                 { | 
 |  |  |                     string jsonStr = "{" + | 
 |  |  |                        " \"FileName\":\"" + HFileName + "\"," + | 
 |  |  |                            " \"FormId\":\"QM_InspectBill\"," + | 
 |  |  |                            " \"IsLast\":\"true\"," + | 
 |  |  |                            " \"InterId\":\"" + HInterID + "\"," + | 
 |  |  |                            " \"BillNO\":\"" + HBillNo + "\"," + | 
 |  |  |                            " \"AliasFileName\":\"test\"," + | 
 |  |  |                            " \"SendByte\":\"" + a + "\"," + | 
 |  |  |                        "}"; | 
 |  |  |  | 
 |  |  |                     var ret = client.AttachmentUpload(jsonStr); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 oCN.Commit(); | 
 |  |  | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         ///// <summary> | 
 |  |  |         ///// 生成金蝶云来料检验单 | 
 |  |  |         ///// </summary> | 
 |  |  |         ///// <param name="InterID">工序汇报单主ID</param> | 
 |  |  |         ///// <returns></returns> | 
 |  |  |         //[Route("QCStockInCheckBill/set_SaveQCStockInCheckBill_Json")] | 
 |  |  |         //[HttpGet] | 
 |  |  |         //public object set_SaveQCStockInCheckBill_Json(string HZJOrgNumber, string HMaterNumber, string HUnitNumber, | 
 |  |  |         //    double HCheckQty, double HRightQty, double HBadQty, | 
 |  |  |         //    string HCheckResult, string HSupNumber, | 
 |  |  |         //    string HUseResult, Int64 HSeQ, Int64 HSourceInterID, | 
 |  |  |         //    Int64 HSourceEntryID, string HSourceBillNo, string user, | 
 |  |  |         //    Int64 HWHID, Int64 HSPID, Int64 HSupID, Int64 HKeeperID, | 
 |  |  |         //    Int64 HMaterID, string HSourceBillType, Int64 HSLInterID, | 
 |  |  |         //    Int64 HSLEntryID, string HSLBillNo, Int64 HSLSeQ, string HBillNo, Int64 HInterID,ref string sErrMsg) | 
 |  |  |         //{ | 
 |  |  |         //    WebS.WebService1 oWebs1 = new WebS.WebService1(); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         //    //oWebs1.Url = "http://localhost:9099/WebService1.asmx"; | 
 |  |  |         //    //K3CloudApiClient client = new K3CloudApiClient("http://192.168.80.90/k3cloud/"); | 
 |  |  |         //    if (oWebs1.set_SaveQcStockInCheckBill_New(HZJOrgNumber, HMaterNumber, HUnitNumber, HCheckQty, HRightQty, HBadQty | 
 |  |  |         //        , HCheckResult, HSupNumber, HUseResult, HSeQ, HSourceInterID | 
 |  |  |         //        , HSourceEntryID, HSourceBillNo, user, HWHID, HSPID | 
 |  |  |         //        , HSupID, HKeeperID, HMaterID, HSourceBillType, HSLInterID | 
 |  |  |         //        , HSLEntryID, HSLBillNo, HSLSeQ, HBillNo, HInterID | 
 |  |  |         //        , ref sErrMsg)) | 
 |  |  |         //    { | 
 |  |  |         //        objJsonResult.code = "0"; | 
 |  |  |         //        objJsonResult.count = 1; | 
 |  |  |         //        objJsonResult.Message = "生成单据成功!"; | 
 |  |  |         //        objJsonResult.data = null; | 
 |  |  |         //        return objJsonResult; | 
 |  |  |         //    } | 
 |  |  |         //    else | 
 |  |  |         //    { | 
 |  |  |         //        objJsonResult.code = "0"; | 
 |  |  |         //        objJsonResult.count = 0; | 
 |  |  |         //        objJsonResult.Message = "生成单据失败!"; | 
 |  |  |         //        objJsonResult.data = sErrMsg; | 
 |  |  |         //        return objJsonResult; | 
 |  |  |         //    } | 
 |  |  |         //} | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         #region 不良品处理单关闭/反关闭功能 | 
 |  |  |         [Route("Sc_ProcessMangement/CloseSc_ProcessMangement")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object CloseSc_ProcessMangement(string HInterID, int Type, string user) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 //判断是否有删除权限 | 
 |  |  |                 if (!DBUtility.ClsPub.Security_Log("QC_NoPassProdCheckBill_Close", 1, false, user)) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "无权限关闭!"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 if (string.IsNullOrWhiteSpace(HInterID)) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "HInterID为空!"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 ClsPub.CurUserName = user; | 
 |  |  |                 BillOld.MvarItemKey = "QC_NoPassProdCheckBillMain"; | 
 |  |  |                 oCN.BeginTran();//开始事务 | 
 |  |  |  | 
 |  |  |                 //Type 1 关闭  2  反关闭 | 
 |  |  |                 if (Type == 1) | 
 |  |  |                 { | 
 |  |  |                     //判断单据是否已经关闭 | 
 |  |  |                     DataSet ds; | 
 |  |  |                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; | 
 |  |  |                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); | 
 |  |  |                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) | 
 |  |  |                     { | 
 |  |  |                         if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") | 
 |  |  |                         { | 
 |  |  |                             objJsonResult.code = "0"; | 
 |  |  |                             objJsonResult.count = 0; | 
 |  |  |                             objJsonResult.Message = "单据已关闭!不需要再关闭!"; | 
 |  |  |                             objJsonResult.data = null; | 
 |  |  |                             return objJsonResult; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     //关闭单据 | 
 |  |  |                     if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) | 
 |  |  |                     { | 
 |  |  |                         objJsonResult.code = "0"; | 
 |  |  |                         objJsonResult.count = 1; | 
 |  |  |                         objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo; | 
 |  |  |                         objJsonResult.data = null; | 
 |  |  |                         return objJsonResult; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |                 else | 
 |  |  |                 { | 
 |  |  |                     //判断单据是否已经反关闭 | 
 |  |  |                     DataSet ds; | 
 |  |  |                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; | 
 |  |  |                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); | 
 |  |  |                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) | 
 |  |  |                     { | 
 |  |  |                         if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "") | 
 |  |  |                         { | 
 |  |  |                             objJsonResult.code = "0"; | 
 |  |  |                             objJsonResult.count = 0; | 
 |  |  |                             objJsonResult.Message = "单据已反关闭!不需要再反关闭!"; | 
 |  |  |                             objJsonResult.data = null; | 
 |  |  |                             return objJsonResult; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     //反关闭单据 | 
 |  |  |                     if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) | 
 |  |  |                     { | 
 |  |  |                         objJsonResult.code = "0"; | 
 |  |  |                         objJsonResult.count = 1; | 
 |  |  |                         objJsonResult.Message = "反关闭失败!原因:" + ClsPub.sExeReturnInfo; | 
 |  |  |                         objJsonResult.data = null; | 
 |  |  |                         return objJsonResult; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 oCN.Commit();//提交事务 | 
 |  |  |  | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 1; | 
 |  |  |                 objJsonResult.Message = "执行成功!"; | 
 |  |  |                 objJsonResult.data = null; | 
 |  |  |                 return objJsonResult; ; | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |             catch (Exception e) | 
 |  |  |             { | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 0; | 
 |  |  |                 objJsonResult.Message = "执行失败!" + e.ToString(); | 
 |  |  |                 objJsonResult.data = null; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         /// <summary> | 
 |  |  |         /// PDA工序汇报单保存 | 
 |  |  |         /// </summary> |