| | |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 生成金蝶云产品检验单 |
| | | /// </summary> |
| | | /// <param name="InterID">工序汇报单主ID</param> |
| | | /// <returns></returns> |
| | | [Route("SCStockInCheckBill/set_SaveSCStockInCheckBill_Json")] |
| | | [HttpGet] |
| | | public object set_SaveSCStockInCheckBill_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, |
| | | 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) |
| | | { |
| | | try |
| | | { |
| | | //获取生产汇报单最大InterID和单据号 |
| | | Int64 HInterID = DBUtility.ClsPub.CreateBillID("7501", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | string HBillNo = DBUtility.ClsPub.CreateBillCode("7501", ref DBUtility.ClsPub.sExeReturnInfo, true); |
| | | |
| | | //保存 |
| | | oCN.BeginTran(); |
| | | //生成产品检验单 |
| | | //oCN.RunProc("Insert Into QC_POStockInCheckBillMain " + |
| | | //"(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate,HBillStatus,HChecker,HCheckDate" + |
| | | //",HYear,HPeriod,HRemark,HSupID,HMaterID" + |
| | | //",HInstockQty,HCheckQty,HRightQty,HBadQty,HFirstCheckEmp" + |
| | | //",HCheckerResult,HSteelStoveNo,HSteelCompReport,HAspect,HSize" + |
| | | //") " + |
| | | //" values('7503','7503'," + HInterID.ToString() + ",'" + HBillNo + "',getdate(),'" + user + "',getdate(),2,'" + user + "',getdate()" + |
| | | //",DATENAME(YEAR,GETDATE()),0,''," + HSupID.ToString() + "," + HMaterID.ToString() + |
| | | //",'" + HCheckQty.ToString() + "','" + HCheckQty.ToString() + "','" + HRightQty.ToString() + "','" + HBadQty.ToString() + "','" + HKeeperID.ToString() + "'" + |
| | | //",'" + HCheckResult.ToString() + "','', '','',''" + |
| | | //") "); |
| | | ////生产汇报单子表 |
| | | //oCN.RunProc("Insert into QC_POStockInCheckBillSub " + |
| | | // " (HInterID,HEntryID,HCloseMan,HCloseType" + |
| | | // ",HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" + |
| | | // ",HRelationQty,HRelationMoney,HQCCheckClassID,HQCCheckItemID,HQCStd," + |
| | | // "HResult,HQCRelValue,HProcCheckEmp,HProcCheckTime" + |
| | | // ") values(" |
| | | // + HInterID.ToString() + ",1,'',''" + |
| | | // ",''," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo.ToString() + "','" + HSourceBillType.ToString() + "'" + |
| | | // ",0,0,0,0,''" + |
| | | // ",'" + HCheckResult.ToString() + "','" + HCheckResult.ToString() + "','" + HKeeperID.ToString() + "',getdate()" + |
| | | // ") "); |
| | | //同步金蝶 |
| | | //访问金蝶 |
| | | var loginRet = InvokeHelper.Login(); |
| | | var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>(); |
| | | if (isSuccess == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "操作失败,金蝶账号登录异常。" + loginRet; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | JObject model = new JObject(); |
| | | model.Add("FBillTypeID", new JObject() { ["Fnumber"] = "JYD002_SYS" }); //单据类型 产品检验单JYD002_SYS |
| | | model.Add("FBusinessType", "3"); //业务类型 |
| | | 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("FISSYNCED", "false");// 是否已同步 |
| | | 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("FInspectResult", HCheckResult.ToString());// 检验结果 |
| | | FentityModel.Add("FQCStatus", "1");// 质检状态 |
| | | FentityModel.Add("FIsRelated", false);// 不良品关联标志 |
| | | FentityModel.Add("FSrcBillType0", "SFC_OperationReport");// 源单类型 |
| | | 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("FCurrency", new JObject() { ["Fnumber"] = "PRE001" });//币别 |
| | | FentityModel.Add("FIsSplitRow ", false);// 是否拆分行 |
| | | |
| | | 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", false); //判退 |
| | | FentityModel2.Add("FIsRelatedDefect", false); //不良品关联标志 |
| | | Fentity2.Add(FentityModel2); |
| | | FentityModel.Add("FPolicyDetail", Fentity2); |
| | | |
| | | |
| | | |
| | | //JArray Fentity3 = new JArray(); |
| | | //JObject FentityModel3 = new JObject(); |
| | | //FentityModel3.Add("FSrcBillType", "SFC_OperationReport"); //源单类型 |
| | | //FentityModel3.Add("FSrcBillNo", HSLBillNo.ToString()); //工序汇报单单号 |
| | | //FentityModel3.Add("FSrcInterId", HSLInterID.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()); //工序计划单号 |
| | | //FentityModel3.Add("FOrderId", HSourceInterID.ToString()); //工序计划主ID |
| | | //FentityModel3.Add("FOrderEntryId", HSourceEntryID.ToString()); //工序计划子ID |
| | | //FentityModel3.Add("FOrderEntrySeq", HSeQ.ToString()); //工序计划行号 |
| | | //Fentity3.Add(FentityModel3); |
| | | //FentityModel.Add("FReferDetail", Fentity3); |
| | | Fentity.Add(FentityModel); |
| | | model.Add("FEntity", Fentity); //明细信息 |
| | | JObject jsonRoot = new JObject() |
| | | { |
| | | ["Creator"] = "", |
| | | ["NeedUpDateFields"] = new JArray(), |
| | | ["NeedReturnFields"] = new JArray(), |
| | | ["IsDeleteEntry"] = "false", |
| | | ["SubSystemId"] = "", |
| | | ["IsVerifyBaseDataField"] = "false", |
| | | //["IsAutoSubmitAndAudit"] = true,//自动调用提交和审核功能 |
| | | ["Model"] = model |
| | | }; |
| | | |
| | | string result = InvokeHelper.Save("QM_InspectBill", JsonConvert.SerializeObject(jsonRoot));//保存 |
| | | //判断保存是否成功 |
| | | if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") |
| | | { |
| | | LogService.Write("来料检验单保存错误jsonRoot:" + jsonRoot); |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = $"来料检验单同步金蝶云失败!单号:{HBillNo.ToString()}" + result; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //提交审核 |
| | | string result1 = string.Empty; |
| | | string result2 = string.Empty; |
| | | var fID = JObject.Parse(result)["Result"]["Id"].ToString(); |
| | | var fBillNo = JObject.Parse(result)["Result"]["Number"].ToString(); |
| | | var json = new |
| | | { |
| | | Ids = fID, |
| | | }; |
| | | result1 = InvokeHelper.Submit("QM_InspectBill", JsonConvert.SerializeObject(json));//提交 |
| | | result2 = InvokeHelper.Audit("QM_InspectBill", JsonConvert.SerializeObject(json));//提交 |
| | | if (JObject.Parse(result1)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = $"来料检验单号:{fBillNo},提交失败" + result; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "保存成功!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 返回生产汇报单列表 |
| | | ///参数:string sql。 |