yxj
昨天 da2b3cb087fb3dad59ac2570a6365194031ea1e5
新增检验单上传生成金蝶云单据调用方法
3个文件已修改
1个文件已添加
606 ■■■■■ 已修改文件
Model/质检管理/ClsQC_POStockInCheckBillSub.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/条码管理/WEBSController.cs 547 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Models/KingdeeResponse.cs 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/WebAPI.csproj 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Model/Öʼì¹ÜÀí/ClsQC_POStockInCheckBillSub.cs
@@ -48,6 +48,11 @@
        public Int64 HInspectMethodID;  // æ£€éªŒæ–¹æ³•
        public Int64 HInspectBasisID;   // æ£€éªŒä¾æ®
        public decimal HInspectValQ; // æ£€éªŒå€¼(定量分析)
        public Int64 HMaterID;      //物料ID
        public double HInStockQty;  //入库数量
        public double HCheckQty;    //抽检数量
        public double HRightQty;    //合格数量
        public double HBadQty;      //不合格数量
    }
}
WebAPI/Controllers/ÌõÂë¹ÜÀí/WEBSController.cs
@@ -5250,6 +5250,553 @@
        #endregion
        #region æ£€éªŒå•    ä¸Šä¼ ç”Ÿå•
        #region æ£€éªŒå•    åˆæ ¼å“
        /// <summary>
        /// æ£€éªŒå•新增上传
        /// </summary>
        /// <returns></returns>
        [Route("WEBSController/set_SaveQCPOStockInCheckBill_Json")]
        [HttpPost]
        public object set_SaveQCPOStockInCheckBill_Json(Int64 HInterID, string HBillNo, string HSourceBillType, string HSourceBillNo, Int64 HSourceInterID, string sHSourceEntryID, Int64 HFirstCheckEmp, string HMaker)
        {
            try
            {
               ClsQC_POStockInCheckBillMain oMain = new ClsQC_POStockInCheckBillMain();
                oMain.HInterID = HInterID;
                oMain.HBillNo = HBillNo;
                oMain.HBillType = "7503";
                oMain.HDate = DateTime.Today;
                oMain.HMainSourceBillType = HSourceBillType;
                oMain.HMainSourceBillNo = HSourceBillNo;
                oMain.HMainSourceInterID = HSourceInterID;
                oMain.HFirstCheckEmp = HFirstCheckEmp;
                oMain.HMaker = HMaker;
                if (set_SaveQCPOStockInCheckBill(oMain, HSourceBillType, sHSourceEntryID, ref DBUtility.ClsPub.sErrInfo))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //成功!
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //失败!
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "检验单上传失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        //生成检验单
        public bool set_SaveQCPOStockInCheckBill(Model.ClsQC_POStockInCheckBillMain oMain, string HSourceBillType, string sHSourceEntryID, ref string sErrMsg)
        {
            string sRemark = "";
            string HReturn;
            //上传前判断
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            DataSet BfDs = oCn.RunProcReturn("exec h_p_QC_BeforeUpload_POStockInCheckBill " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + HSourceBillType + "','" + sHSourceEntryID + "'," + oMain.HFirstCheckEmp.ToString(), "h_p_QC_BeforeUpload_POStockInCheckBill");
            if (BfDs == null || BfDs.Tables[0].Rows.Count == 0)
            {
                sErrMsg = "上传前判断数据完整性失败!";
                return false;
            }
            else
            {
                if (DBUtility.ClsPub.isLong(BfDs.Tables[0].Rows[0][0]) == 1)
                {
                    sErrMsg = "单据号:" + oMain.HBillNo + ",单据ID:" + oMain.HInterID + ";" + DBUtility.ClsPub.isStrNull(BfDs.Tables[0].Rows[0]["HRemark"]);
                    return false;
                }
            }
            sRemark = sRemark + " ï¼›ä¸Šä¼ å‰åˆ¤æ–­" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
            //返回所需数据
            DataSet Ds;
            Ds = oCn.RunProcReturn("exec h_p_QC_POStockInCheckBill_CLD " + oMain.HMainSourceInterID.ToString() + ",'" + sHSourceEntryID + "'," + oMain.HFirstCheckEmp.ToString(), "h_p_QC_POStockInCheckBill_CLD");
            if (Ds == null || Ds.Tables[0].Rows.Count == 0 || Ds.Tables[1].Rows.Count == 0)
            {
                sErrMsg = "根据收料通知单:" + oMain.HMainSourceBillNo + " èŽ·å–æ•°æ®å¤±è´¥ï¼";
                return false;
            }
            sRemark = sRemark + " ï¼›èŽ·å–CLOUD单据API递入值" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
            //获取单据主表所需数据
            oMain.HSupID = Pub_Class.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSupID"]);
            oMain.HSTOCKORGID = Pub_Class.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSTOCKORGID"]);
            //获取系统参数
            Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
            if (oSystemParameter.ShowBillByOrgID(oMain.HSTOCKORGID, ref sErrMsg) == false)
            {
                sErrMsg = "获取系统参数失败! " + sErrMsg;
                return false;
            }
            try
            {
                //判断会计期是否合理
                string s = "";
                int sYear = 0;
                int sPeriod = 0;
                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(oMain.HDate, ref sYear, ref sPeriod, ref s) == false)
                {
                    sErrMsg = s;
                    return false;
                }
                oMain.HYear = sYear;
                oMain.HPeriod = sPeriod;
                oCn.BeginTran();
                //生成检验单
                //写入主表
                oCn.RunProc("Insert Into QC_POStockInCheckBillMain " +
                "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate" +
                ",HYear,HPeriod,HRemark,HSTOCKORGID,HSupID,HMaterID" +
                ",HInstockQty,HCheckQty,HRightQty,HBadQty,HFirstCheckEmp" +
                ",HCheckerResult,HSteelStoveNo,HSteelCompReport,HAspect,HSize" +
                ") " +
                " values('" + oMain.HBillType + "','" + oMain.HBillType + "'," + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + oMain.HDate.ToShortDateString() + "','" + oMain.HMaker + "',getdate()" +
                ", " + oMain.HYear.ToString() + "," + oMain.HPeriod.ToString() + ",'" + oMain.HRemark + "'," + oMain.HSTOCKORGID.ToString() + "," + oMain.HSupID.ToString() + "," + oMain.HMaterID.ToString() +
                ", " + oMain.HCheckQty.ToString() + "," + oMain.HCheckQty.ToString() + "," + oMain.HRightQty.ToString() + "," + oMain.HBadQty.ToString() + "," + oMain.HFirstCheckEmp.ToString() +
                ",'" + oMain.HCheckerResult + "','" + oMain.HSteelStoveNo + "','" + oMain.HSteelCompReport + "','" + oMain.HAspect + "','" + oMain.HSize + "'" +
                ") ");
                //写入子表
                for (int i = 0; i < Ds.Tables[1].Rows.Count; i++)
                {
                    Model.ClsQC_POStockInCheckBillSub oSub = new Model.ClsQC_POStockInCheckBillSub();
                    oSub.HEntryID = i + 1;
                    oSub.HSourceInterID = Pub_Class.ClsPub.isLong(Ds.Tables[1].Rows[i]["HSourceInterID"]);
                    oSub.HSourceEntryID = Pub_Class.ClsPub.isLong(Ds.Tables[1].Rows[i]["HSourceEntryID"]);
                    oSub.HSourceBillNo = Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["HSourceBillNo"]);
                    oSub.HSourceBillType = Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["HSourceBillType"]);
                    oSub.HResult = "合格";
                    oSub.HProcCheckEmp = oMain.HFirstCheckEmp;
                    oSub.HMaterID = Pub_Class.ClsPub.isLong(Ds.Tables[1].Rows[i]["HMaterID"]);
                    oSub.HInStockQty = Pub_Class.ClsPub.isDoule(Ds.Tables[1].Rows[i]["HInStockQty"]);
                    oSub.HCheckQty = Pub_Class.ClsPub.isDoule(Ds.Tables[1].Rows[i]["HCheckQty"]);
                    oSub.HRightQty = Pub_Class.ClsPub.isDoule(Ds.Tables[1].Rows[i]["HRightQty"]);
                    oSub.HBadQty = Pub_Class.ClsPub.isDoule(Ds.Tables[1].Rows[i]["HBadQty"]);
                    oCn.RunProc("Insert Into QC_POStockInCheckBillSub " +
                    "(HInterID,HEntryID,,HBillNo_bak,HRemark" +
                    ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" +
                    ",HQCCheckClassID,HQCCheckItemID,HQCStd,HQCRelValue" +
                    "HResult,HProcCheckEmp,HProcCheckTime" +
                    "HMaterID,HInStockQty,HCheckQty,HRightQty,HBadQty" +
                    ") " +
                    " values(" + oMain.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oMain.HBillNo + "','" + oSub.HRemark + "'" +
                    ", " + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'" +
                    ", " + oSub.HQCCheckClassID.ToString() + "," + oSub.HQCCheckItemID.ToString() + ",'" + oSub.HQCStd + "','" + oSub.HQCRelValue + "'" +
                    ",'" + oSub.HResult + "'," + oSub.HProcCheckEmp.ToString() + "',getdate()" +
                    ", " + oSub.HMaterID.ToString() + "," + oSub.HInStockQty.ToString() + "," + oSub.HCheckQty.ToString() + "," + oSub.HRightQty.ToString() + "," + oSub.HBadQty.ToString() +
                    ") ");
                }
                sRemark = sRemark + " ï¼›ç”Ÿæˆæ£€éªŒå•单据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                //获取金蝶云API所需递入数据
                string sJson_MainCustom = "";   //主表自定义字段
                sJson_MainCustom = Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["MainCustom"]);
                string sJson_Main = "{\"Creator\":\"\",\"NeedUpDateFields\":[],\"NeedReturnFields\":[],\"IsDeleteEntry\":\"True\",\"SubSystemId\":\"\",\"IsVerifyBaseDataField\":\"false\",\"IsEntryBatchFill\":\"True\",\"Model\":{\"FBillNo\":\"" + oMain.HBillNo + "\"," +
                    //\"FID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FID"]) + "\"," +
                    "\"FBillTypeID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBillTypeID"]) + "\" }," +
                    "\"FBusinessType\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBusinessType"]) + "\"," +
                    "\"FDATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FDATE"]) + "\"," +
                    "\"FSourceOrgId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSourceOrgId"]) + "\"}," +
                    "\"FInspectOrgId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FInspectOrgId"]) + "\"}," +
                    "\"FInspectDepId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FInspectDepId"]) + "\"}," +
                    //"\"FInspectGroupId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FInspectGroupId"]) + "\"}," +
                    "\"FInspectorId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FInspectorId"]) + "\"}," +
                    //"\"FDescription\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FDescription"]) + "\"," +
                    //"\"FUpScanBox\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FUpScanBox"]) + "\"," +
                    //"\"FDefScanBox\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FDefScanBox"]) + "\"," +
                    //"\"FCheckQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FCheckQty"]) + "\"," +
                    //"\"FInspectValScanBox\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FInspectValScanBox"]) + "\"," +
                    "\"FIsSynced\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FIsSynced"]) + "\"," +
                    sJson_MainCustom +
                    "\"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_FProduceDate = "";     //生产日期
                    string sJson_FExpiryDate = "";      //有效期至
                    string sJson_FAUXPROPID = "";
                    string sJson_SubCustom = "";        //子表自定义字段
                    //子表自定义字段
                    sJson_SubCustom = Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["SubCustom"]);
                    //是否启用批次管理
                    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]["FISKFPERIOD"]) == "1")
                    {
                        sJson_FProduceDate = " \"FProduceDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FProduceDate"]) + "\",";
                        sJson_FExpiryDate = " \"FExpiryDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FExpiryDate"]) + "\",";
                    }
                    else
                    {
                        sJson_FProduceDate = "";
                        sJson_FExpiryDate = "";
                    }
                    //是否启用仓位
                    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"]) + "\"}},";
                    }
                    //辅助属性
                    sJson_FAUXPROPID = " \"FAUXPROPID\":{\"FAUXPROPID__FF100002\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FAUXPROPID"]) + "\"}},";
                    sJson_Entry = sJson_Entry + "{" +
                    //"FEntryID": 0,
                    "\"FMaterialId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMaterialId"]) + "\"}," +
                    //"FQCSchemeId": {"FNUMBER": ""},
                    "\"FUnitID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FUnitID"]) + "\"}," +
                    "\"FInspectQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FInspectQty"]) + "\"," +            //检验数量
                    "\"FQualifiedQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FQualifiedQty"]) + "\"," +        //合格数量
                    "\"FUnqualifiedQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FUnqualifiedQty"]) + "\"," +    //不合格数量
                    //"FSampleDamageQty": 0,
                    //"FSUnqualifiedQty": 0,
                    "\"FInspectResult\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FInspectResult"]) + "\"," +      //检验结果
                    "\"FQCStatus\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FQCStatus"]) + "\"," +                //质检状态
                    //"FBaseSUnqualifiedQty": 0,
                    //"FSampleQty": 0,
                    //"FMemo": "",
                    "\"FIsRelated\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FIsRelated"]) + "\"," +
                    "\"FSrcBillType0\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcBillType0"]) + "\"," +
                    "\"FSrcBillNo0\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcBillNo0"]) + "\"," +
                    "\"FSrcInterId0\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcInterId0"]) + "\"," +
                    "\"FSrcEntryId0\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcEntryId0"]) + "\"," +
                    "\"FSrcEntrySeq0\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcEntrySeq0"]) + "\"," +
                    "\"FBaseUnitId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseUnitId"]) + "\"}," +
                    //"FQCBusinessType": "",
                    //"FBFLowId": {"FNAME": ""},
                    //"FSampleSchemeId": {"FNUMBER": ""},
                    //"FAcceptQty": 0,
                    //"FRejectQty": 0,
                    //"FInspectEndDate": "1900-01-01",
                    "\"FBaseInspectQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseInspectQty"]) + "\"," +        //基本单位检验数量
                    "\"FSupplierId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSupplierId"]) + "\"}," +
                    //"FCustomerId": {"FNUMBER": ""},
                    //"FProductLineId": {"FNUMBER": ""},
                    //"FPrdLineLocation": {"FLOCATIONCODE": ""},
                    //"FWorkshopId": {"FNUMBER": ""},
                    "\"FStockId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockId"]) + "\"}," +
                    sJson_BatchNo +
                    "\"FInspectTimes\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FInspectTimes"]) + "\"," +            //检验次数
                    sJson_StockPlace +
                    //"FConsumeTime": 0,
                    //"FInspectStartDate": "1900-01-01",
                    "\"FTimeUnit\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTimeUnit"]) + "\"," +
                    //"FBaseSampleDamageQty": 0,
                    //"FBaseUnqualifiedQty": 0,
                    //"FOperNumber": 0,
                    "\"FSampleDamageBearer\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSampleDamageBearer"]) + "\"," +
                    "\"FIsFirstInspect\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FIsFirstInspect"]) + "\"," +
                    "\"FBaseQualifiedQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseQualifiedQty"]) + "\"," +    //基本单位合格数
                    "\"FBaseAcceptQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseAcceptQty"]) + "\"," +          //基本单位接收数
                    sJson_FAUXPROPID +
                    //"FPrdUnitId": {"FNumber": ""},
                    //"FBaseReAcceptQty": 0,
                    //"FOperDescription": "",
                    //"FUnitTransHeadQty": 0,
                    //"FUnitTransOperQty": 0,
                    //"FSNUnitID": {"FNumber": ""},
                    //"FBaseWBInspectQty": 0,
                    //"FBaseUnQuaSalQty": 0,
                    //"FSupplierLot": "",
                    sJson_FProduceDate +
                    sJson_FExpiryDate +
                    //"FNewExpiryDate": "1900-01-01",
                    "\"FCurrency\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCurrency"]) + "\"}," +
                    //"FDiscountQty": 0,
                    "\"FIsSplitRow\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FIsSplitRow"]) + "\"," +
                    sJson_SubCustom +
                    //使用决策表体
                    "\"FPolicyDetail\": [ {  " +
                    //"FDetailID": 0,
                    "\"FPolicyMaterialId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPolicyMaterialId"]) + "\"}," +
                    "\"FPolicyStatus\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPolicyStatus"]) + "\"," +
                    "\"FPolicyQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPolicyQty"]) + "\"," +
                    "\"FBasePolicyQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBasePolicyQty"]) + "\"," +
                    "\"FUsePolicy\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FUsePolicy"]) + "\"," +
                    //"FSerialId": { "FNUMBER": ""},
                    "\"FIsCheck\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FIsCheck"]) + "\"," +
                    "\"FIsDefectProcess\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FIsDefectProcess"]) + "\"," +
                    "\"FCanSale\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCanSale"]) + "\"," +
                    "\"FIsMRBReview\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FIsMRBReview"]) + "\"," +
                    "\"FIsReturn\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FIsReturn"]) + "\"," +
                    "\"FIsRelatedDefect\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FIsRelatedDefect"]) + "\"" +
                    //"FMRBReviewStatus": "",
                    //"FBoxNumber": "",
                    //"FMemo1": "",
                    //"FPolicyAuxPropId": {"FPOLICYAUXPROPID__FF100005": { "FNumber": ""},"FPOLICYAUXPROPID__FF100002": { "FNumber": ""}}
                    " } ]," +
                    //缺陷记录表体
                    //"\"FDefectDetail\": [ {  " +
                    ////"FDetailID": 0,
                    ////"FDSerialId": {"FNUMBER": ""},
                    ////"FDefectTypeId": {"FNUMBER": ""},
                    ////"FDefectQty": 0,
                    ////"FBaseDefectQty1": 0,
                    ////"FDefectReasonId": {"FNUMBER": ""},
                    ////"FDefectLevel": "",
                    ////"FDefectResultId": {"FNUMBER": ""},
                    ////"FDefectMemo": ""
                    //" } ]," +
                    //检验项目表体
                    //"\"FItemDetail\": [ {  " +
                    ////"FDetailID": 0,
                    ////"FInspectItemId": { "FNUMBER": ""},
                    ////"FInspectResult1": "",
                    ////"FAnalysisMethod": "",
                    ////"FQualityStdId": { "FNUMBER": ""},
                    ////"FUnitId2": { "FNUMBER": ""},
                    ////"FInspectValQ": 0,
                    ////"FInspectValB": { "FNUMBER": ""},
                    ////"FInspectValT": "",
                    ////"FInspectMethodId": { "FNUMBER": ""},
                    ////"FInspectInstrumentId": { "FNUMBER": ""},
                    ////"FDefectlevel1": "",
                    ////"FDestructInspect": "false",
                    ////"FKeyInspect": "false",
                    ////"FInspectBasisId": { "FNUMBER": ""},
                    ////"FSampleSchemeId1": { "FNUMBER": ""},
                    ////"FItemStatus": "",
                    ////"FCompareSymbol": "",
                    ////"FSampleQty1": 0,
                    ////"FAcceptQty1": 0,
                    ////"FRejectQty1": 0,
                    ////"FSampleDamageQty1": 0,
                    ////"FBaseSampleDamageQty1": 0,
                    ////"FItemMemo": "",
                    ////"FSUnqualifiedQty1": 0,
                    ////"FBaseSUnqualifiedQty1": 0,
                    ////"FTargetVal": "",
                    ////"FInspectVal": "",
                    ////"FUpLimit": "",
                    ////"FDownLimit": "",
                    ////"FUpOffset": "",
                    ////"FDownOffset": "",
                    ////"FInspectValKey": "",
                    ////"FTargetValKey": "",
                    ////"FUpLimitKey": "",
                    ////"FDownLimitKey": "",
                    ////"FUpOffsetKey": "",
                    ////"FDownOffsetKey": "",
                    ////"FTargetValQ": 0,
                    ////"FUpLimitQ": 0,
                    ////"FDownLimitQ": 0,
                    ////"FUpOffsetQ": 0,
                    ////"FDownOffsetQ": 0,
                    ////"FTargetValB": { "FNUMBER": ""},
                    ////"FUpLimitB": { "FNUMBER": ""},
                    ////"FDownLimitB": { "FNUMBER": ""},
                    ////"FUpOffsetB": { "FNUMBER": ""},
                    ////"FDownOffsetB": { "FNUMBER": ""},
                    ////"FTargetValT": "",
                    ////"FUpLimitT": "",
                    ////"FDownLimitT": "",
                    ////"FUpOffsetT": "",
                    ////"FDownOffsetT": "",
                    ////"FValueGrid": [
                    ////    {
                    ////    "FGridId": 0,
                    ////    "FInspectResult2": "",
                    ////    "FInspectValueB": { "FNUMBER": ""},
                    ////    "FInspectValueT": "",
                    ////    "FInspectValue": 0,
                    ////    "FVSerialId": { "FNUMBER": ""}
                    ////    }
                    ////]
                    //" } ]," +
                    //参考表体
                    "\"FReferDetail\": [ {  " +
                    //"FDetailID": 0,
                    "\"FSrcBillType\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcBillType"]) + "\"," +
                    "\"FSrcBillNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcBillNo"]) + "\"," +
                    "\"FSrcInterId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcInterId"]) + "\"," +
                    "\"FSrcEntryId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcEntryId"]) + "\"," +
                    "\"FSrcEntrySeq\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcEntrySeq"]) + "\"," +
                    "\"FOrderType\":{\"FID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOrderType"]) + "\"}," +
                    "\"FOrderBillNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOrderBillNo"]) + "\"," +
                    "\"FOrderId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOrderId"]) + "\"," +
                    "\"FOrderEntryId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOrderEntryId"]) + "\"," +
                    "\"FOrderEntrySeq\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOrderEntrySeq"]) + "\"" +
                    " } ]," +
                    //关联关系表
                    "\"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"]) + "\"," +
                    "\"FEntity_Link_FBaseAcceptQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FBaseAcceptQty"]) + "\"," +
                    "\"FEntity_Link_FBaseAcceptQtyOld\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FBaseAcceptQtyOld"]) + "\"," +
                    "\"FEntity_Link_FBaseInspectQtyOld\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FBaseInspectQtyOld"]) + "\"," +
                    "\"FEntity_Link_FInspectQtyOld\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FInspectQtyOld"]) + "\"" +
                    " } ]   }  ";
                }
                string sJson_End = "  ]  }}";
                string sJson = sJson_Main + sJson_Entry + sJson_End;
                //CLOUD金蝶云账号密码登入
                var loginRet = InvokeHelper.LoginUser(oMain.HMaker);
                var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
                sRemark = sRemark + " ï¼›èŽ·å–éªŒè¯CLOUD账号密码" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                //生成金蝶云单据
                if (isSuccess == 1)
                {
                    string result = InvokeHelper.Save("QM_InspectBill", sJson); //保存
                    sRemark = sRemark + " ï¼›ç”ŸæˆCLOUD单据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                    HReturn = result.ToString();
                    if (HReturn.Contains("\"IsSuccess\":false") == true)
                    {
                        //反序列化json数据
                        var retModel = JsonConvert.DeserializeObject<KingdeeResponse>(HReturn);
                        //接收金蝶报错信息
                        var strErrorMsg = string.Empty;
                        //遍历获取报错信息
                        foreach (var item in retModel.Result.ResponseStatus.Errors)
                        {
                            strErrorMsg += item.Message + "\r\n";
                        };
                        sErrMsg = "生成检验单失败!金蝶云提示:" + strErrorMsg;
                        LogService.Write("生成检验单失败!" + HReturn + sJson);   //写入txt文本
                        oCn.RollBack();
                        return false;
                    }
                    else
                    {
                        sRemark = sRemark + sJson;
                        oCn.Commit();
                    }
                }
                else
                {
                    sErrMsg = "生成检验单失败!金蝶云登录失败!";
                    oCn.RollBack();
                    return false;
                }
            }
            catch (Exception e)
            {
                LogService.Write("生成回滚" + e.Message + sRemark);
                sErrMsg = "生成检验单失败!" + e.Message;
                oCn.RollBack();
                return false;
            }
            if (oSystemParameter.omodel.QC_POStockInCheckBill_AutoCheck.ToUpper() == "Y") //系统参数  è‡ªåŠ¨å®¡æ ¸
            {
                try
                {
                    oCn.BeginTran();
                    //审核WMS单据
                    oCn.RunProc("Update QC_POStockInCheckBillMain Set HChecker='" + oMain.HMaker + "',HCheckDate=getdate(),HBillStatus=2 where HInterID= " + oMain.HInterID.ToString());
                    //提交、审核金蝶云单据
                    HReturn = "";
                    string sJson2 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
                    var result2 = InvokeHelper.Submit("QM_InspectBill", sJson2);    //提交
                    sRemark = sRemark + " ï¼›æäº¤CLOUD单据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                    var result3 = InvokeHelper.Audit("QM_InspectBill", sJson2);     //审核
                    sRemark = sRemark + " ï¼›å®¡æ ¸CLOUD单据" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
                    HReturn = result2.ToString() + "," + result3.ToString();
                    if (HReturn.Contains("\"IsSuccess\":false") == true)
                    {
                        //反序列化json数据
                        var retModel = JsonConvert.DeserializeObject<KingdeeResponse>(result3);
                        //接收金蝶报错信息
                        var strErrorMsg = string.Empty;
                        //遍历获取报错信息
                        foreach (var item in retModel.Result.ResponseStatus.Errors)
                        {
                            strErrorMsg += item.Message + "\r\n";
                        };
                        sErrMsg = "生成检验单成功,审核单据失败!金蝶云提示:" + strErrorMsg;
                        LogService.Write("审核单据失败" + sRemark + HReturn);
                        oCn.RollBack();
                        return true;
                    }
                    else
                    {
                        LogService.Write("生成并审核检验单成功!" + sRemark);
                        sErrMsg = "生成并审核检验单成功!单据号为:" + oMain.HBillNo;
                        oCn.Commit();
                        return true;
                    }
                }
                catch (Exception e)
                {
                    LogService.Write("审核回滚" + sRemark + HReturn);
                    sErrMsg = "审核检验单失败!" + e.Message;
                    oCn.RollBack();
                    return false;
                }
            }
            else
            {
                LogService.Write("生成检验单成功!" + sRemark);
                sErrMsg = "生成检验单成功!单据号为:" + oMain.HBillNo;
                return true;
            }
        }
        #endregion
        #endregion
        #region ç”Ÿäº§ç»„托单    ä¸Šä¼ ç”Ÿå•
        /// <summary>
WebAPI/Models/KingdeeResponse.cs
New file
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WebAPI.Models
{
    public class KingdeeResponse
    {
        public _Result Result { get; set; }
    }
    public class _Result
    {
        public _ResponseStatus ResponseStatus { get; set; }
    }
    public class _ResponseStatus
    {
        public int ErrorCode { get; set; }
        public bool IsSuccess { get; set; }
        private List<_Error> _errors;
        public List<_Error> Errors
        {
            get; set;
        } = new List<_Error>();
        private List<_SuccessEntity> _successEntitys;
        public List<_SuccessEntity> SuccessEntitys
        {
            get; set;
        }
        public int MsgCode { get; set; }
    }
    public class _Error
    {
        public string FieldName { get; set; }
        public string Message { get; set; }
        public int DIndex { get; set; }
        //错误的单据编号
        public string FNumber { get; set; }
    }
    public class _SuccessEntity
    {
        public int Id { get; set; }
        public string Number { get; set; }
        public int DIndex { get; set; }
    }
}
WebAPI/WebAPI.csproj
@@ -986,6 +986,7 @@
    <Compile Include="Models\Gy_RoutingBillSub_WorkQty.cs" />
    <Compile Include="Models\ClsQC_CheckNote_PNL_Temp.cs" />
    <Compile Include="Models\Gy_TechnologyParameterSub.cs" />
    <Compile Include="Models\KingdeeResponse.cs" />
    <Compile Include="Models\QC_OutCompCheckBillSub_ValueGrid.cs" />
    <Compile Include="Models\Sc_StationOutBillSub_Sup.cs" />
    <Compile Include="Models\Gy_MateNumRelation_Sec.cs" />