yxj
2023-12-14 3fcf6df024ad311ee4d2436d0a80c5adf95dd1d4
WebAPI/DLL/ClsSc_ICMOReportBill.cs
@@ -3,6 +3,9 @@
using System.Text;
using System.Data;
using DBUtility;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using WebAPI.Models;
namespace WebAPI.DLL
{
@@ -11,6 +14,8 @@
        public Models.ClsSc_ICMOReportBillMain omodel = new Models.ClsSc_ICMOReportBillMain();
        public Models.ClsSc_ICMOReportBillSub oSub = new Models.ClsSc_ICMOReportBillSub();
        public List<Models.ClsSc_ICMOReportBillSub> DetailColl = new List<Models.ClsSc_ICMOReportBillSub>();
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
        private json objJsonResult = new json();
        public ClsSc_ICMOReportBill()
        {
@@ -156,31 +161,44 @@
                ",HYear,HPeriod,HRemark,HEmpID,HEmpNumber" +
                ",HGroupID,HDeptID,HDeptNumber" +
                ",HMainSourceBillNo,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillType" +
                ",HChecker,HCheckDate,HUpDater,HUpDateDate,HDeleteMan,HDeleteDate,HPrintQty,HCheckType" +
                ",HERPInterID,HERPBillType,HPRDORGID" +
                ") " +
                " values('" + this.BillType + "','"  + this.HBillSubType + "'," +omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "','" + omodel.HMaker+ "',getdate()" +
                "," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + omodel.HEmpID.ToString() + "','" + omodel.HEmpNumber +
                "','" + omodel.HGroupID.ToString() + "'," + omodel.HDeptID.ToString() + ",'" + omodel.HDeptNumber +
                "','" + omodel.HMainSourceBillNo.ToString() + "'," + omodel.HMainSourceInterID.ToString() + ",'" + omodel.HMainSourceEntryID + "','" + omodel.HMainSourceBillType + "'" +
                "','" + omodel.HMainSourceBillNo.ToString() + "'," + omodel.HMainSourceInterID.ToString() + ",'" + omodel.HMainSourceEntryID + "','" + omodel.HMainSourceBillType + "','" + omodel.HChecker + "','" + omodel.HCheckDate + "','" + omodel.HUpDater +
                "','" + omodel.HUpDateDate + "','" + omodel.HDeleteMan + "','" + omodel.HDeleteDate + "'," + omodel.HPrintQty +
                ",'" + omodel.HCheckType + "'," + omodel.HERPInterID + ",'" + omodel.HERPBillType + "'," + omodel.HPRDORGID +
                ") ");
                //插入子表
                foreach (Models.ClsSc_ICMOReportBillSub oSub in DetailColl)
                {
                    oCn.RunProc("Insert into Sc_ICMOReportBillSub " +
                      " (HInterID,HEntryID,HMaterID,HMaterNumber" +
                      ",HQty,HUnitID,HUnitNumber,HTimes,HSourceID" +
                      ",HQty,HBadQty,HUnitID,HUnitNumber,HTimes,HSourceID" +
                      ",HQtyMust,HWorkerID,HWorkerNumber,HBadCount,HWasterQty," +
                      "HCloseMan,HCloseType,HRemark," +
                      "HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
                      ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" +
                      ",HICMOInterID,HICMOBillNo,HBarCode" +
                      ",HOWNERTYPEID,HISENTRUST,HSTOCKINORGID,HOWNERID,HCHECKPRODUCT,HQAIP,HCOSTRATE,HISBACKFLUSH" +
                      ",HREQSRC,HREQBILLNO,HREQBILLID,HREQENTRYSEQ,HREQENTRYID,HMOMAINENTRYID,HSTOCKINQUASELQTY" +
                      ",HPRODUCTTYPE,HPROJECTNO,HICMOENTRYSEQ,HSEQ,HPRODUCEDATE,HEXPIRYDATE,HBASEUNITID,HDEPTID" +
                      ",HGroupID,HDESCRIPTION" +
                      ",HSourceNumber,HQPQty,HICMOEntryID" +
                      ",HWhID,HSPID,HBatChNo,HAuxPropID,HMTONo,HPlanMode,HERPInterID,HERPEntryID" +
                      ") values("
                      + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HMaterID.ToString() + ",'" + oSub.HMaterNumber + "'" +
                      "," + oSub.HQty.ToString() + "," + oSub.HUnitID.ToString() + ",'" + oSub.HUnitNumber + "'," + oSub.HTimes.ToString() + "," + oSub.HSourceID.ToString() +
                      "," + oSub.HQty.ToString() + "," + oSub.HBadQty.ToString() + "," + oSub.HUnitID.ToString() + ",'" + oSub.HUnitNumber + "'," + oSub.HTimes.ToString() + "," + oSub.HSourceID.ToString() +
                      "," + oSub.HQtyMust.ToString() + "," + oSub.HWorkerID.ToString() + ",'" + oSub.HWorkerNumber + "'," + oSub.HBadCount.ToString() + "," + oSub.HWasterQty.ToString() +
                      ",'" + oSub.HCloseMan + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
                      "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
                      "," + oSub.HSourceInterID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
                      "," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'" +
                      "," + oSub.HICMOInterID.ToString() + ",'" + oSub.HICMOBillNo + "','" + oSub.HBarCode + "'" +
                      "," + oSub.HICMOInterID.ToString() + ",'" + oSub.HICMOBillNo + "','" + oSub.HBarCode + "','" + oSub.HOWNERTYPEID + "'," +
                      oSub.HISENTRUST + "," + oSub.HSTOCKINORGID + "," + oSub.HOWNERID + "," + oSub.HCHECKPRODUCT + ",'" + oSub.HQAIP + "'," +
                      oSub.HCOSTRATE + "," + oSub.HISBACKFLUSH + ",'" + oSub.HREQSRC + "','" + oSub.HREQBILLNO + "'," + oSub.HREQBILLID + "," +
                      oSub.HREQENTRYSEQ + "," + oSub.HREQENTRYID + "," + oSub.HMOMAINENTRYID + "," + oSub.HSTOCKINQUASELQTY + "," + oSub.HPRODUCTTYPE + ",'" + oSub.HPROJECTNO + "'," + oSub.HICMOENTRYSEQ + "," + oSub.HSEQ + ",'" + oSub.HPRODUCEDATE + "','" + oSub.HEXPIRYDATE + "'," + oSub.HBASEUNITID + "," + oSub.HDEPTID + "," + oSub.HGroupID + ",'" + oSub.HDESCRIPTION + "','" + oSub.HSourceNumber + "'," + oSub.HQPQty + ","  + oSub.HSourceEntryID + ","  + oSub.HICMOEntryID + ","  +  oSub.HWhID + "," + oSub.HSPID + ",'" + oSub.HBatChNo + "'," + oSub.HAuxPropID + ",'" + oSub.HMTONo + "'," + oSub.HPlanMode + "," + oSub.HERPInterID + "," + oSub.HERPEntryID +
                      ") ");
                }
                //
@@ -318,6 +336,217 @@
                oCn.BeginTran();
                oCn.RunProc(" Update " + MvarItemKey + " set HBillStatus='2',HChecker='" + HChecker + "',HCheckDate='" + HCheckDate + "' Where HInterID=" + lngBillKey.ToString());
                DataSet ds,Ds;
                ds = oCn.RunProcReturn("select * from  Sc_ICMOReportBillMain where HInterID = " + lngBillKey, "Sc_ICMOReportBillMain");
                string HBillNo = "";
                if (ds.Tables[0].Rows.Count > 0)
                {
                    HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
                }
                Ds = oCn.RunProcReturn("exec h_p_Kf_GetICMOReportBill_ICMO_CLD_WorkQty " + lngBillKey.ToString() + ",'" + HBillNo + "'", "h_p_Kf_GetICMOReportBill_ICMO_CLD_WorkQty");
                if (Ds == null || Ds.Tables[0].Rows.Count == 0 || Ds.Tables[1].Rows.Count == 0)
                {
                    LogService.Write("生产汇报单审核,获取json子表信息失败");
                    oCn.RollBack();
                    return false;
                }
                else
                {
                    LogService.Write("获取json子表信息成功");
                    string sJson_ZYMESFLAG = "";    //生产汇报单同步MES标记
                    sJson_ZYMESFLAG = Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FHZYMESFLAG"]);
                    string sJson_Main = "{\"Creator\":\"\",\"NeedUpDateFields\":[],\"NeedReturnFields\":[],\"IsDeleteEntry\":\"True\",\"SubSystemId\":\"\",\"IsVerifyBaseDataField\":\"false\"," +
                        "\"IsEntryBatchFill\":\"false\",\"ValidateFlag\":\"True\",\"NumberSearch\":\"True\",\"InterationFlags\":\"\"," +
                        "\"Model\": { \"FBILLNO\":\"" + HBillNo + "\"," +
                        //"\"FID\":\"" + oMain.HInterID.ToString() + "\"," +
                        "\"FBillType\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBillType"]) + "\"}," +
                        //\"FDocumentStatus\":\"\",
                        "\"FDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FDate"]) + "\"," +
                        "\"FPRDORGID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPRDORGID"]) + "\"}," +
                        //\"FWorkshipIdH\":{\"FNumber\":\"\"},
                        //\"FDescription\":\"\",
                        sJson_ZYMESFLAG +
                        "\"FEntity\": [   ";
                    string sJson_Entry = "";
                    for (int i = 0; i < Ds.Tables[1].Rows.Count; i++)
                    {
                        if (sJson_Entry != "")
                        {
                            sJson_Entry = sJson_Entry + " , ";
                        }
                        string sJson_BatchNo = "";
                        string sJson_StockPlace = "";
                        string sJson_EntryCustom = "";
                        if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["HISBATCHMANAGE"]) == "1") //是否启用批次管理
                        {
                            sJson_BatchNo = "  \"FLOT\": {\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLOT"]) + "\"},    \"FLOT_TEXT\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLOT"]) + "\"  , ";
                        }
                        else
                        {
                            sJson_BatchNo = "";
                        }
                        //仓位
                        if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKLOCID"]) == "")
                        {
                            sJson_StockPlace = "";
                        }
                        else
                        {
                            sJson_StockPlace = Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKLOCID"]) + "\"}},";
                        }
                        //自定义字段处理
                        if (oSystemParameter.omodel.WMS_CampanyName == "四维尔") //系统参数  客户定制化名称     空白为通用
                        {
                            sJson_EntryCustom = "\"FBILLSTATUS\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBILLSTATUS"]) + "\"," +         //单据状态
                                                "\"F_abcd_Datetime\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["F_abcd_Datetime"]) + "\","; //计划开工日期
                        }
                        //
                        sJson_Entry = sJson_Entry + " {" +
                        //" \"FEntryID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["HEntryID"]) + "," +
                        " \"FSRCENTRYID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCENTRYID"]) + "," +
                        " \"FIsNew\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FIsNew"]) + "," +
                        " \"FMATERIALID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMATERIALID"]) + "\"}," +
                        " \"FPRODUCTTYPE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRODUCTTYPE"]) + "\"," +
                        " \"FREPORTTYPE\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FREPORTTYPE"]) + "\"}," +
                        " \"FUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FUNITID"]) + "\"}," +
                        " \"FWORKSHIPID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FWORKSHOPID"]) + "\"}," +
                        //\"FShiftGroupId\":{\"FNumber\":\"\"},
                        sJson_BatchNo +
                        //\"FDeptId\":{\"FNumber\":\"\"},
                        sJson_StockPlace +
                        " \"FMTONO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMTONO"]) + "\"," +
                        " \"FCHECKPRODUCT\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCHECKPRODUCT"]) + "," +
                        " \"FISENTRUST\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FISENTRUST"]) + "," +
                        " \"FSRCBILLTYPE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBILLTYPE"]) + "\"," +
                        " \"FMOBILLNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMOBILLNO"]) + "\"," +
                        " \"FAUXPROPID\":{\"FAUXPROPID__FF100002\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FAUXPROPID"]) + "\"}}," +
                        //\"FHumanQty\":\"0\",
                        " \"FSRCBILLNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBILLNO"]) + "\"," +
                        //\"FMachineQty\":\"0\",
                        //\"FMaterialUnitID\":{\"FNumber\":\"\"},
                        //\"FStartTime\":\"1900-01-01\",
                        //\"FEndTime\":\"1900-01-01\",
                        //\"FTimeUnitId\":\"\",
                        " \"FMOENTRYSEQ\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMOENTRYSEQ"]) + "," +
                        //" \"FSTANDHOURUNITID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTANDHOURUNITID"]) + "\"," +
                        " \"FPROJECTNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPROJECTNO"]) + "\"," +
                        " \"FSTDMANHOUR\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTDMANHOUR"]) + "," +
                        " \"FHRPREPARETIME\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FHRPREPARETIME"]) + "," +
                        //\"FHrWorkTime\":\"0\",
                        " \"FMACPREPARETIME\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMACPREPARETIME"]) + "," +
                        //\"FMacWorkTime\":\"0\",
                        //\"FDescriptionE\":\"\",
                        " \"FSRCINTERID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCINTERID"]) + "," +
                        " \"FSRCENTRYSEQ\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCENTRYSEQ"]) + "," +
                        " \"FMOID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMOID"]) + "," +
                        " \"FMOENTRYID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMOENTRYID"]) + "," +
                        " \"FBASEUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBASEUNITID"]) + "\"}," +
                        " \"FSTOCKINORGID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKINORGID"]) + "\"}," +
                        " \"FBOMID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBOMID"]) + "\"}," +
                        " \"FOWNERTYPEID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOWNERTYPEID"]) + "\"," +
                        " \"FOWNERID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOWNERID"]) + "\"}," +
                        " \"FSTOCKID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKID"]) + "\"}," +
                        " \"FCOSTRATE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCOSTRATE"]) + "," +
                        " \"FSNUNITID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSNUNITID"]) + "\"}," +
                        //\"FSNQty\":\"0\",
                        //\"FProduceDate\":\"1900-01-01\",
                        //\"FExpiryDate\":\"1900-01-01\",
                        " \"FISBACKFLUSH\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FISBACKFLUSH"]) + "," +
                        " \"FMOMAINENTRYID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMOMAINENTRYID"]) + "," +
                        " \"FQAIP\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FQAIP"]) + "\"," +
                        " \"FREQSRC\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FREQSRC"]) + "\"," +
                        " \"FREQBILLNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FREQBILLNO"]) + "\"," +
                        " \"FREQBILLID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FREQBILLID"]) + "," +
                        " \"FREQENTRYSEQ\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FREQENTRYSEQ"]) + "," +
                        " \"FREQENTRYID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FREQENTRYID"]) + "," +
                        " \"FBASEQUAQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBASEQUAQTY"]) + "," +
                        " \"FQUAQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FQUAQTY"]) + "," +
                        " \"FBASEFINISHQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBASEFINISHQTY"]) + "," +
                        " \"FFINISHQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FFINISHQTY"]) + "," +
                        sJson_EntryCustom +
                        //\"FSerialSubEntity\":[{\"FDetailID\":\"0\",
                        //\"FQCMaterialId\":{\"FNUMBER\":\"\"},
                        //\"FInspectResult\":\"\",
                        //\"FQcAuxPropId\":{\"FQCAUXPROPID__FF100002\":{\"FNumber\":\"\"}},
                        //\"FQCQty\":\"0\",
                        //\"FSerialNo\":\"\",
                        //\"FSerialId\":{\"FNUMBER\":\"\"},
                        //\"FQCStockInSelQty\":\"0\",
                        //\"FSerialNote\":\"\",
                        //\"FBaseQCQty\":\"0\",
                        //\"FBaseQCStockInSelQty\":\"0\"}]
                        " \"FEntity_Link\": [{" +
                            " \"FEntity_Link_FFlowId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FFlowId"]) + "\"," +
                            " \"FEntity_Link_FFlowLineId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FFlowLineId"]) + "\"," +
                            " \"FEntity_Link_FRuleId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FRuleId"]) + "\"," +
                            " \"FEntity_Link_FSTableName\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FSTableName"]) + "\"," +
                            " \"FEntity_Link_FSBillId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FSBillId"]) + "\"," +
                            " \"FEntity_Link_FSId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FSId"]) + "\"" +
                        " } ]," +
                        " \"FBFLOWID\":{\"FID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBFLOWID"]) + "\"}}";
                    }
                    string sJson_End = "  ]  }}";
                    string sJson = sJson_Main + sJson_Entry + sJson_End;
                    //从配置文件获取 CLOUD网址、账套信息、登录用户、登录密码
                    if (!Pub_Class.ClsPub.GetCLOUDLoginInfo(ref Pub_Class.ClsPub.sExeReturnInfo))
                    {
                        LogService.Write("生产汇报单审核,同步获取登录账号密码失败");
                        return false;
                    }
                    var loginRet = InvokeHelper.Login();
                    var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
                    if (isSuccess == 0)
                    {
                        oCn.RollBack();
                        return false;
                    }
                    else
                    {
                        LogService.Write("开始调用保存方法");
                        string result = InvokeHelper.Save("PRD_MORPT", JsonConvert.SerializeObject(sJson));//保存
                        if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
                        {
                            LogService.Write("生产汇报错误jsonRoot:" + sJson);
                            oCn.RollBack();
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = $"生产汇报单同步金蝶云失败!单号:{HBillNo.ToString()}" + result + sJson;
                            objJsonResult.data = null;
                            return false;
                        }
                        //提交审核
                        string result1 = string.Empty;
                        string result2 = string.Empty;
                        if (oSystemParameter.omodel.Sc_ICMOReportBill_AutoCheck == "Y") //系统参数  自动审核
                        {
                            result1 = InvokeHelper.Submit("PRD_MORPT", JsonConvert.SerializeObject(sJson));//提交
                            result2 = InvokeHelper.Audit("PRD_MORPT", JsonConvert.SerializeObject(sJson));//审核
                            if (JObject.Parse(result1)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
                            {
                                oCn.RollBack();
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = $"生产汇报单单号:{HBillNo},提交失败" + result;
                                objJsonResult.data = null;
                                return false;
                            }
                        }
                    }
                }
                sReturn = "审核单据成功!";
                oCn.Commit();
@@ -354,6 +583,42 @@
            }
        }
        //删除单据
        public virtual bool DeleteBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                oCn.BeginTran();
                //查询生产汇报单表数量
                DataSet ds = oCn.RunProcReturn("select a.HBillNo,b.HSourceInterID,b.HSourceEntryID  from Sc_ICMOReportBillMain a inner join Sc_ICMOReportBillSub b on a.HInterID = b.HInterID where a.HInterID = '" + lngBillKey + "'", "Sc_ICMOReportBillMain");
                string HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
                string HSourceInterID = ds.Tables[0].Rows[0]["HSourceInterID"].ToString();
                string HSourceEntryID = ds.Tables[0].Rows[0]["HSourceEntryID"].ToString();
                //
                //更新产量汇报临时表是否报检申请状态
                string sql1 = string.Format(@"update Sc_ICMOBillWorkQtyStatus_Tmp set HRelationInterID='0' where HICMOReportBillNo='"+ HBillNo + "' and HICMOInterID='"+ HSourceInterID + "' and HICMOEntryID='"+ HSourceEntryID + "'");
                oCn.RunProc(sql1);
                //删除关联
                DeleteRelation(ref sReturn, lngBillKey);
                //删除明细表
                DeleteBillSub(lngBillKey);
                //删除主表
                DeleteBillMain(lngBillKey);
                sReturn = "删除单据成功!";
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                throw (e);
            }
        }
        //扫码生成产量汇报单(无条码出入库记录)
        public bool AddBill_PDA2(ref string sReturn)