yusijie
2024-12-05 30ea66a7a0cf43413f483a873ba2675c52b7d6fa
WebAPI/Controllers/²Ö´æ¹ÜÀí/ÁìÁÏ·¢»õ/Kf_MateOutBillController.cs
@@ -1,4 +1,5 @@
using DBUtility;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
@@ -17,17 +18,19 @@
        private json objJsonResult = new json();
        public DataSet ds = new DataSet();
        public SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
        public DLL.ClsKf_MateOutBill BillNew0 = new DLL.ClsKf_MateOutBill();   //模具报废入库对应单据类
        public DLL.ClsKf_MateOutBill BillOld0 = new DLL.ClsKf_MateOutBill();   //模具报废入库对应单据类
        #region ç”Ÿäº§é¢†æ–™å•列表
        [Route("Kf_MateOutBill/GetMateOutBillList")]
        [HttpGet]
        public object GetMateOutBillList(string sWhere,string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();  //定义声明变量 ï¼ŒæŠŠé€šè¿‡ new List<object>()创建的 å®žä¾‹ï¼Œèµ‹å€¼ç»™å˜é‡
                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Kf_MateOutBillQuery", 1, false, user))
                {
@@ -39,13 +42,19 @@
                }
                ds = oCn.RunProcReturn("select * from h_v_IF_MateOutBillList_Search " + sWhere + " order by æ—¥æœŸ desc, hmainid desc", "h_v_IF_MateOutBillList_Search");
                foreach (DataColumn col in ds.Tables[0].Columns)//遍历ds中第一个表(Tables[0])的所有列(Columns)每次循环中,col变量会持有当前列的引用
                {
                    Type dataType = col.DataType; //获取当前数据类型传入 è‡ªå®šä¹‰å˜é‡datadataType
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //字符串拼接         // å°†åˆ—名和数据类型信息拼接成一个JSON格式的字符串
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
                //{
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
                //}
                //else
@@ -126,6 +135,17 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //进行 ä¼šè®¡æœŸé—´ ç»“è´¦ çš„判断和控制
                int sYear = 0;
                int sPeriod = 0;
                DateTime HDate = DateTime.Now;
                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
                {
                    objJsonResult.Message = s;
                    return objJsonResult;
                }
                bool IsDete = oBill.DeleteBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo);
                if (IsDete)
                {
@@ -403,7 +423,7 @@
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (sqlWhere == null || sqlWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn(string.Format(@"select HMaterID ,物料代码 HMaterCode ,物料名称 HMaterName,物料公式 HMaterRuleType,规格型号 HMaterSpec,用量 HRate,HUnitID,计量单位代码 HUnitCode,计量单位 HUnitName,应收数量 HQtyMust,实收数量 HQty,单价 HPrice,金额 HMoney,HWHID,领料仓库代码 HWHCode,领料仓库 HWHName,表体备注 HRemark
                    ds = oCN.RunProcReturn(string.Format(@"select HMaterID ,物料代码 HMaterCode ,物料名称 HMaterName,物料公式 HMaterRuleType,规格型号 HMaterSpec,用量 HRate,HUnitID,计量单位代码 HUnitCode,计量单位 HUnitName,应收数量 HQtyMust,实收数量 HQty,单价 HPrice,金额 HMoney,HWHID,领料仓库代码 HWHCode,领料仓库 HWHName,表体备注 HRemark,实际称重 HWeight
from h_v_IF_MateOutBillList"), "H_V_IF_MATEOUTBILLLIST");
                }
@@ -411,7 +431,7 @@
                {
                    //string sql1 = "select HRepairCheckID,HRepairCheckContent,HManagerID,HRemark  from Sc_MouldRepairCheckBillSub where 1 = 1 ";
                    string sql1 = string.Format(@"select HMaterID ,物料代码 HMaterCode ,物料名称 HMaterName,物料公式 HMaterRuleType,规格型号 HMaterSpec,用量 HRate, HUnitID,计量单位代码 HUnitCode,计量单位 HUnitName,应收数量 HQtyMust,实收数量 HQty,单价 HPrice,金额 HMoney,HWHID,领料仓库代码 HWHCode,领料仓库 HWHName,表体备注 HRemark
                    string sql1 = string.Format(@"select HMaterID ,物料代码 HMaterCode ,物料名称 HMaterName,物料公式 HMaterRuleType,规格型号 HMaterSpec,用量 HRate, HUnitID,计量单位代码 HUnitCode,计量单位 HUnitName,应收数量 HQtyMust,实收数量 HQty,单价 HPrice,金额 HMoney,HWHID,领料仓库代码 HWHCode,领料仓库 HWHName,表体备注 HRemark, å®žé™…称重 HWeight
from h_v_IF_MateOutBillList WHERE 1=1");
                    string sql = sql1 + sqlWhere + " order by HSubID asc";
                    ds = oCN.RunProcReturn(sql, "H_V_IF_MATEOUTBILLLIST");
@@ -597,6 +617,16 @@
                    oBill.DetailColl.Add(oItemSub);
                }
                //进行 ä¼šè®¡æœŸé—´ ç»“è´¦ çš„判断和控制
                int sYear = 0;
                int sPeriod = 0;
                DateTime HDate = DateTime.Now;
                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
                {
                    objJsonResult.Message = s;
                    return objJsonResult;
                }
                //保存
                //保存完毕后处理
                bool bResult;
@@ -864,10 +894,20 @@
                    return objJsonResult;
                }
                //进行 ä¼šè®¡æœŸé—´ ç»“è´¦ çš„判断和控制
                string s = "";
                int sYear = 0;
                int sPeriod = 0;
                DateTime HDate = DateTime.Now;
                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
                {
                    objJsonResult.Message = s;
                    return objJsonResult;
                }
                //进行需要进行的审核/反审核操作
                if (IsAudit == 0) //审核提交
                {
                {
                    //审核提交
                    if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
@@ -887,7 +927,7 @@
                    }
                }
                if (IsAudit == 1) //反审核提交
                {
                {
                    //反审核提交AbandonCheck
                    if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
@@ -1200,5 +1240,349 @@
            }
        }
        #endregion
        #region æ ¹æ®å•据号,同步生产领料单
        [Route("Kf_MateOutBillController/GetKf_MateOutBill_Sync_Json")]
        [HttpGet]
        public json GetKf_MateOutBill_Sync_Json(string HBillNo, string HBillType)
        {
            try
            {
                //获取系统参数
                string sql = string.Empty;
                string sErrMsg = "";
                if (oSystemParameter.ShowBill(ref sErrMsg) == true)
                {
                    //系统参数是否为私有云模式,N为公有云模式,Y为私有云模式
                    //私有云模式,通过调用存储过程进行同步
                    if (oSystemParameter.omodel.WMS_CloudMode.ToUpper() == "Y")
                    {
                        ds = oCn.RunProcReturn("exec h_p_IFCLD_ERPSourceBillToLocal_MateOut '" + HBillNo + "'", "h_p_IFCLD_ERPSourceBillToLocal_MateOut");
                        if (ds == null || ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据同步发生错误!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) == 2)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            else
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 1;
                                objJsonResult.Message = "单据同步成功!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                        }
                    }
                    //公有云模式,通过调用WEBAPI方式进行同步
                    else if (oSystemParameter.omodel.WMS_CloudMode.ToUpper() == "N")
                    {
                        //判断金蝶云是否登录成功
                        var loginRet = InvokeHelper.Login();
                        var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
                        //判断是否登录成功
                        if (isSuccess <= 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "同步失败,金蝶云登入不成功,请确认C盘配置文件所设置金蝶云对应网址、账套、登录用户、登录密码是否正确!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        var json = new
                        {
                            CreateOrgId = 0,
                            Number = HBillNo,
                            Id = ""
                        };
                        //查看 èŽ·å–æ•°æ®
                        var _result = InvokeHelper.View("PRD_PickMtrl", JsonConvert.SerializeObject(json));
                        var _saveObj = JObject.Parse(_result);
                        //判断金蝶云数据是否获取成功
                        if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "金蝶云生产领料单获取失败:" + _result;
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        oCn.BeginTran();
                        //查找本地生产领料单表中是否存在该单据,存在获取本单单据ID,不存在则获取最大单据ID
                        Int64 HNewInterID = 0;
                        ds = oCn.RunProcReturn("select HInterID from Kf_ICStockBillMain with(nolock) where HBillNo = '" + HBillNo + "' and HBillType='1204'", "Kf_ICStockBillMain");
                        if (ds == null || ds.Tables[0].Rows.Count == 0)
                        {
                            HNewInterID = DBUtility.ClsPub.CreateBillID_Prod(HBillType, ref sErrMsg);
                        }
                        else
                        {
                            HNewInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HInterID"]);
                        }
                        //根据单据号删除本地生产领料单中对应单据
                        oCn.RunProc("Delete b from Kf_ICStockBillMain a inner join Kf_ICStockBillSub b on a.HInterID=b.HInterID where a.HBillNo = '" + HBillNo + "' and a.HBillType='1204'", ref DBUtility.ClsPub.sExeReturnInfo);
                        oCn.RunProc("Delete from Kf_ICStockBillMain where HBillNo = '" + HBillNo + "' and HBillType='1204'", ref DBUtility.ClsPub.sExeReturnInfo);
                        //主表数据赋值
                        var MainData = new
                        {
                            HInterID = HNewInterID,
                            HBillNo = DBUtility.ClsPub.isStrNull(_saveObj["Result"]["Result"]["BillNo"]),
                            HBillType = "1204",
                            HBillSubType = "1204",
                            HMainSourceBillType = "",
                            HDate = DBUtility.ClsPub.isDate(_saveObj["Result"]["Result"]["Date"]),
                            HSupID = 0,
                            HWHID = 0,
                            HSCWHID = 0,
                            HEmpID = 0,
                            HManagerID = 0,
                            HSecManagerID = DBUtility.ClsPub.isLong(_saveObj["Result"]["Result"]["PickerId_Id"]),
                            HKeeperID = DBUtility.ClsPub.isLong(_saveObj["Result"]["Result"]["FSTOCKERID_Id"]),
                            HDeptID = 0,
                            HCurID = DBUtility.ClsPub.isLong(_saveObj["Result"]["Result"]["CurrId_Id"]),
                            HSeOrderBillNo = "",
                            HExplanation = "CLD导入",
                            HRemark = "",
                            HInnerBillNo = "",
                            HRedBlueFlag = 0,
                            HBillStatus = DBUtility.ClsPub.isLong(_saveObj["Result"]["Result"]["ApproverId_Id"]) == 0 ? 1 : 2,
                            HMaker = DBUtility.ClsPub.isStrNull(_saveObj["Result"]["Result"]["CreatorId"]["Name"]),
                            HMakeDate = DBUtility.ClsPub.isDate(_saveObj["Result"]["Result"]["CreateDate"]),
                            HChecker = DBUtility.ClsPub.isLong(_saveObj["Result"]["Result"]["ApproverId_Id"]) == 0 ? "" : DBUtility.ClsPub.isStrNull(_saveObj["Result"]["Result"]["ApproverId"]["Name"]),
                            HCheckDate = DBUtility.ClsPub.isDate(_saveObj["Result"]["Result"]["ApproveDate"]),
                            HUpDater = DBUtility.ClsPub.isLong(_saveObj["Result"]["Result"]["ModifierId_Id"]) == 0 ? "" : DBUtility.ClsPub.isStrNull(_saveObj["Result"]["Result"]["ModifierId"]["Name"]),
                            HUpDateDate = DBUtility.ClsPub.isDate(_saveObj["Result"]["Result"]["ModifyDate"]),
                            HDeleteMan = DBUtility.ClsPub.isLong(_saveObj["Result"]["Result"]["CANCELER_Id"]) == 0 ? "" : DBUtility.ClsPub.isStrNull(_saveObj["Result"]["Result"]["CANCELER"]["Name"]),
                            HDeleteDate = DBUtility.ClsPub.isDate(_saveObj["Result"]["Result"]["CancelDate"]),
                            HOWNERID = DBUtility.ClsPub.isLong(_saveObj["Result"]["Result"]["OwnerId_Id"]),
                            HOWNERTYPEID = DBUtility.ClsPub.isStrNull(_saveObj["Result"]["Result"]["OwnerTypeId"]),
                            HERPInterID = DBUtility.ClsPub.isLong(_saveObj["Result"]["Result"]["Id"]),
                            HERPBillType = DBUtility.ClsPub.isStrNull(_saveObj["Result"]["Result"]["BillType_Id"]),
                            HERPBillNo = DBUtility.ClsPub.isStrNull(_saveObj["Result"]["Result"]["BillNo"]),
                            HPRDORGID = DBUtility.ClsPub.isLong(_saveObj["Result"]["Result"]["PrdOrgId_Id"]),
                            HSTOCKORGID = DBUtility.ClsPub.isLong(_saveObj["Result"]["Result"]["StockOrgId_Id"]),
                        };
                        //写入主表
                        sql = $@"Insert into Kf_ICStockBillMain
                                    (HInterID,HYear,HPeriod,HBillNo,HBillType,HBillSubType,HMainSourceBillType,HDate
                                    ,HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID,HKeeperID,HDeptID,HCurID
                                    ,HSeOrderBillNo,HExplanation,HRemark,HInnerBillNo,HRedBlueFlag,HBillStatus
                                    ,HMaker,HMakeDate
                                    ,HChecker,HCheckDate
                                    ,HUpDater,HUpDateDate
                                    ,HDeleteMan,HDeleteDate
                                    ,HOWNERID,HOWNERTYPEID,HERPInterID,HERPBillType,HERPBillNo
                                    ,HPRDORGID,HSTOCKORGID)
                                    Values({MainData.HInterID},year('{MainData.HDate}'),month('{MainData.HDate}'),'{MainData.HBillNo}','{MainData.HBillType}','{MainData.HBillSubType}','{MainData.HMainSourceBillType}','{MainData.HDate}'
                                    , {MainData.HSupID},{MainData.HWHID},{MainData.HSCWHID},{MainData.HEmpID},{MainData.HManagerID},{MainData.HSecManagerID},{MainData.HKeeperID},{MainData.HDeptID},{MainData.HCurID}
                                    ,'{MainData.HSeOrderBillNo}','{MainData.HExplanation}','{MainData.HRemark}','{MainData.HInnerBillNo}',{MainData.HRedBlueFlag},{MainData.HBillStatus}
                                    ,'{MainData.HMaker}','{MainData.HMakeDate}'
                                    ,'{MainData.HChecker}',case when '{MainData.HCheckDate}' = '1900/1/1 0:00:00' then NULL else '{MainData.HCheckDate}' end
                                    ,'{MainData.HUpDater}',case when '{MainData.HUpDateDate}' = '1900/1/1 0:00:00' then NULL else '{MainData.HUpDateDate}' end
                                    ,'{MainData.HDeleteMan}',case when '{MainData.HDeleteDate}' = '1900/1/1 0:00:00' then NULL else '{MainData.HDeleteDate}' end
                                    , {MainData.HOWNERID},'{MainData.HOWNERTYPEID}',{MainData.HERPInterID},'{MainData.HERPBillType}','{MainData.HERPBillNo}'
                                    , {MainData.HPRDORGID},{MainData.HSTOCKORGID})";
                        oCn.RunProc(sql.Replace("\r\n", ""));
                        //子表数据赋值
                        var dataArr = _saveObj["Result"]["Result"]["Entity"];
                        foreach (var oSub in dataArr)
                        {
                            var subData = new
                            {
                                HInterID = HNewInterID,
                                HEntryID = DBUtility.ClsPub.isLong(oSub["Id"]),
                                HMTONo = DBUtility.ClsPub.isStrNull(oSub["MTONO"]),
                                HPlanMode = 0,
                                HRemark = "",
                                HExpressNumber = "",
                                HMaterID = DBUtility.ClsPub.isLong(oSub["MaterialId_Id"]),
                                HUnitID = DBUtility.ClsPub.isLong(oSub["UnitId_Id"]),
                                HBatchNo = DBUtility.ClsPub.isStrNull(oSub["Lot_Text"]),
                                HPropertyID = DBUtility.ClsPub.isLong(oSub["AuxPropId_Id"]),
                                HWHID = DBUtility.ClsPub.isLong(oSub["StockId_Id"]),
                                HSPID = DBUtility.ClsPub.isLong(oSub["StockLocId_Id"]),
                                HSCWHID = 0,
                                HSCSPID = 0,
                                HQtyMust = DBUtility.ClsPub.isDoule(oSub["AppQty"]),
                                HQty = DBUtility.ClsPub.isDoule(oSub["ActualQty"]),
                                HPrice = DBUtility.ClsPub.isDoule(oSub["FPrice"]),
                                HMoney = DBUtility.ClsPub.isDoule(oSub["FAmount"]),
                                HTaxPrice = DBUtility.ClsPub.isDoule(oSub["FPrice"]),
                                HTaxRate = 1,
                                HTaxMoney = DBUtility.ClsPub.isDoule(oSub["FAmount"]),
                                HRelationQty = DBUtility.ClsPub.isDoule(oSub["SelPrcdReturnQty"]),
                                HRelationMoney = 0,
                                HSourceInterID = DBUtility.ClsPub.isLong(oSub["SrcInterId"]),
                                HSourceEntryID = DBUtility.ClsPub.isLong(oSub["SrcEnteryId"]),
                                HSourceBillNo = DBUtility.ClsPub.isStrNull(oSub["SrcBillNo"]),
                                HSourceBillType = DBUtility.ClsPub.isStrNull(oSub["SrcBillType"]),
                                HERPInterID = DBUtility.ClsPub.isLong(_saveObj["Result"]["Result"]["Id"]),
                                HERPEntryID = DBUtility.ClsPub.isLong(oSub["Id"]),
                                HERPBillNo_Sub = "",
                                HPOOrderInterID = 0,
                                HPOOrderEntryID = 0,
                                HPOOrderBillNo = "",
                                HSeOrderInterID = 0,
                                HSeOrderEntryID = 0,
                                HSeOrderBillNo = "",
                                HICMOInterID = DBUtility.ClsPub.isLong(oSub["MoId"]),
                                HICMOEntryID = DBUtility.ClsPub.isLong(oSub["MoEntryId"]),
                                HICMOBillNo = DBUtility.ClsPub.isStrNull(oSub["MoBillNo"]),
                                HWWOrderInterID = 0,
                                HWWOrderEntryID = 0,
                                HWWOrderBillNo = "",
                                HProduceDate = DBUtility.ClsPub.isDate(oSub["ProduceDate"]),
                                HExpiryDate = DBUtility.ClsPub.isDate(oSub["ExpiryDate"]),
                                HOWNERID = DBUtility.ClsPub.isLong(oSub["OwnerId_Id"]),
                                HOWNERTYPEID = DBUtility.ClsPub.isStrNull(oSub["OwnerTypeId"]),
                                HKEEPERID = DBUtility.ClsPub.isLong(oSub["KeeperId_Id"]),
                                HKEEPERTYPEID = DBUtility.ClsPub.isStrNull(oSub["KeeperTypeId"]),
                            };
                            //写入子表
                            sql = $@"Insert into Kf_ICStockBillSub
                                       (HInterID,HEntryID,HMTONo,HPlanMode,HRemark,HExpressNumber
                                       ,HMaterID,HUnitID,HBatchNo,HPropertyID,HWHID,HSPID,HSCWHID,HSCSPID
                                       ,HQtyMust,HQty,HPrice,HMoney,HTaxPrice,HTaxRate,HTaxMoney,HRelationQty,HRelationMoney
                                       ,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HERPInterID,HERPEntryID,HERPBillNo_Sub
                                       ,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo
                                       ,HICMOInterID,HICMOEntryID,HICMOBillNo,HWWOrderInterID,HWWOrderEntryID,HWWOrderBillNo
                                       ,HProduceDate
                                        ,HExpiryDate
                                        ,HOWNERID,HOWNERTYPEID,HKEEPERID,HKEEPERTYPEID)
                                        Values ({subData.HInterID},{subData.HEntryID},'{subData.HMTONo}',{subData.HPlanMode},'{subData.HRemark}','{subData.HExpressNumber}'
                                        ,{subData.HMaterID},{subData.HUnitID},'{subData.HBatchNo}',{subData.HPropertyID},{subData.HWHID},{subData.HSPID},{subData.HSCWHID},{subData.HSCSPID}
                                        ,{subData.HQtyMust},{subData.HQty},{subData.HPrice},{subData.HMoney},{subData.HTaxPrice},{subData.HTaxRate},{subData.HTaxMoney},{subData.HRelationQty},{subData.HRelationMoney}
                                        ,{subData.HSourceInterID},{subData.HSourceEntryID},'{subData.HSourceBillNo}','{subData.HSourceBillType}',{subData.HERPInterID},{subData.HERPEntryID},'{subData.HERPBillNo_Sub}'
                                        ,{subData.HPOOrderInterID},{subData.HPOOrderEntryID},'{subData.HPOOrderBillNo}',{subData.HSeOrderInterID},{subData.HSeOrderEntryID},'{subData.HSeOrderBillNo}'
                                        ,{subData.HICMOInterID},{subData.HICMOEntryID},'{subData.HICMOBillNo}',{subData.HWWOrderInterID},{subData.HWWOrderEntryID},'{subData.HWWOrderBillNo}'
                                        ,case when '{subData.HProduceDate}' = '1900/1/1 0:00:00' then NULL else '{subData.HProduceDate}' end
                                        ,case when '{subData.HExpiryDate}' = '1900/1/1 0:00:00' then NULL else '{subData.HExpiryDate}' end
                                        ,{subData.HOWNERID},'{subData.HOWNERTYPEID}',{subData.HKEEPERID},'{subData.HKEEPERTYPEID}')";
                            oCn.RunProc(sql.Replace("\r\n", ""));
                        }
                        oCn.Commit();
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "单据同步成功!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "不支持同步功能!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "获取系统参数失败! " + sErrMsg;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "单据同步失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region æ¡ç æ˜Žç»†
        /// <summary>
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <returns></returns>
        [Route("Kf_MateOutBillController/BarCodeNote")]
        [HttpGet]
        public object SellOutBill_BarCodeNote(int HInterID)
        {
            try
            {
                List<object> columnNameListSum = new List<object>();
                List<object> columnNameList0 = new List<object>();
                List<object> columnNameList1 = new List<object>();
                List<object> columnNameList2 = new List<object>();
                string sql = "exec  h_p_IFCLD_ERPSourceBillToLocal_MateOut " + HInterID;
                ds = oCn.RunProcReturn(sql, " h_p_IFCLD_ERPSourceBillToLocal_MateOut");
                //添加 åŸºæœ¬ä¿¡æ¯ åˆ—名
                foreach (DataColumn col in ds.Tables[1].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList0.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                //添加 ç å•信息 åˆ—名
                foreach (DataColumn col in ds.Tables[2].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList1.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                //添加 æ¡ç æ˜Žç»† åˆ—名
                foreach (DataColumn col in ds.Tables[3].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList2.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                columnNameListSum.Add(columnNameList0);
                columnNameListSum.Add(columnNameList1);
                columnNameListSum.Add(columnNameList2);
                List<DataTable> tableList = new List<DataTable>();
                tableList.Add(ds.Tables[1]);
                tableList.Add(ds.Tables[2]);
                tableList.Add(ds.Tables[3]);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = tableList;
                objJsonResult.list = columnNameListSum;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}