llj
9 天以前 da093f633f4aefd2dff51000126109e111af772b
WebAPI/Controllers/XSGL/Xs_SeOutStockBackBillController.cs
@@ -91,6 +91,62 @@
            }
        }
        #endregion
        #region 返回退货通知单列表-分页
        [Route("Xs_SeOutStockBackBill/list_byPage")]
        [HttpGet]
        public object list_byPag(string sWhere, string user, string Organization, int page, int size)
        {
            try
            {
                List<object> columnNameList = new List<object>();  //定义声明变量 ,把通过 new List<object>()创建的 实例,赋值给变量
                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Xs_SeOutStockBackBillQuery", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限查询!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                sWhere = sWhere.Replace("'", "''");
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("exec h_p_IF_SeOutStockBackBillListPage " + page + "," + size + ",'" + Organization + "'," + "''", "h_p_IF_SeOutStockBackBillListPage");
                }
                else
                {
                    ds = oCN.RunProcReturn("exec h_p_IF_SeOutStockBackBillListPage " + page + "," + size + ",'" + Organization + "','" + sWhere + "'", "h_p_IF_SeOutStockBackBillListPage");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                objJsonResult.Message = "Sucess!";
                objJsonResult.list = columnNameList;
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 删除功能
        /// <summary>
        ///删除功能
@@ -986,5 +1042,102 @@
            }
        }
        #region [退货通知单同步插件]
        [Route("Xs_SeOutStockBackBill/SaveXs_SeOutStockBackBillApi")]
        [HttpPost]
        public object SaveXs_SeOutStockBackBillApi([FromBody] JObject sMainSub)
        {
            try
            {
                LogService.Write("退货通知单同步:" + sMainSub.ToString());
                var model = sMainSub["model"].ToString();
                var entry = sMainSub["model"]["HENTRY"].ToString();
                model = "[" + model.ToString() + "]";
                List<Model.ClsXs_SeOutStockBackBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsXs_SeOutStockBackBillMain>>(model);
                List<Model.ClsXs_SeOutStockBackBillSub> subList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsXs_SeOutStockBackBillSub>>(entry);
                string sql = string.Empty;
                oCN.BeginTran();
                sql = $"delete Xs_SeOutStockBackBillMain where HinterID = {mainList[0].HInterID}";
                oCN.RunProc(sql);
                sql = $"delete Xs_SeOutStockBackbillSub where HinterID = {mainList[0].HInterID}";
                oCN.RunProc(sql);
                //主表
                sql = "insert into Xs_SeOutStockBackBillMain " +
                "(HInterID,HYear,HPeriod,HBillType,HBillSubType,HDate," +
                "HBillNo,HBillStatus,HCusID,HManagerID,HDeptID,HRemark," +
                "HAddress,HSSID,HCurID,HWHID,HExRate,HEmpID,HExplanation,HInnerBillNo," +
                "HSALEORGID,HDELIVERYORGID,HOWNERID,HOWNERTYPEID," +
                "HMaker,HMakeDate,HChecker,HCheckDate," +
                "HUpDater,HUpDateDate,HDeleteMan,HDeleteDate,HERPInterID,HERPBillType," +
                "HSETTLECUSID,HPAYCUSID,HRECEIVECUSID,HSALEGROUPID,HHEADLOCID,HRECCONTACTID," +
                "HRETURNREASON,HRETDEPTID,HDESCRIPTION,HBUSINESSTYPE" +
                ") values (" +mainList[0].HInterID + ", " + mainList[0].HYear + ", " + mainList[0].HPeriod + ", '" + mainList[0].HBillType + "', '" + mainList[0].HBillSubType + "', '" + mainList[0].HDate + "', " +
                "'" + mainList[0].HBillNo + "', " + mainList[0].HBillStatus + ", " + mainList[0].HCusID + ", " + mainList[0].HManagerID + ", " + mainList[0].HDeptID + ", '" + mainList[0].HRemark + "', " +
                "'" + mainList[0].HAddress + "', " + mainList[0].HSSID + ", " + mainList[0].HCurID + ", " + mainList[0].HWHID + ", " + mainList[0].HExRate + ", " + mainList[0].HEmpID + ", '" + mainList[0].HExplanation + "', '" + mainList[0].HInnerBillNo + "'," +
                " " + mainList[0].HSALEORGID + ", " + mainList[0].HDELIVERYORGID + ", " + mainList[0].HOWNERID + ", '" + mainList[0].HOWNERTYPEID + "', " +
                "'" + mainList[0].HMaker + "', '" + mainList[0].HMakeDate + "', '" + mainList[0].HChecker + "', '" + mainList[0].HCheckDate + "', " +
                "'" + mainList[0].HUpDater + "', '" + mainList[0].HUpDateDate + "', '" + mainList[0].HDeleteMan + "', '" + mainList[0].HDeleteDate + "', " +mainList[0].HERPInterID + ", '" + mainList[0].HERPBillType + "', " +
                "" +  mainList[0].HSETTLECUSID + ", " + mainList[0].HPAYCUSID + ", " + mainList[0].HRECEIVECUSID + ", " + mainList[0].HSALEGROUPID + ", " + mainList[0].HHEADLOCID + ", " + mainList[0].HRECCONTACTID + ", " +
                "'" + mainList[0].HRETURNREASON + "', " + mainList[0].HRETDEPTID + ", '" + mainList[0].HDESCRIPTION + "', '" + mainList[0].HBUSINESSTYPE + "')";
                LogService.Write("退货通知单主表同步:" + sql);
                oCN.RunProc(sql);
                //保存子表
                foreach (var oSub in subList)
                {
                    sql = $@"insert into Xs_SeOutStockBackbillSub
                    (HInterID,HEntryID,HMaterID,HUnitID,HQty,HPrice,
                     HMoney,HTaxMoney,HTaxPrice,HWHID,HRemark,
                     HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HSeOrderInterID,HSeOrderEntryID,HSeORderBillNo,
                     HOWNERID,HOWNERTYPEID,HSETTLEORGID,
                     HRelationQty,HAuxPropID,HBatchNO,HMTONo,HERPInterID,HERPEntryID,
                     HSOBILLTYPEID,HRMTYPE,HSTOCKUNITID,HBASEUNITID,HDELIVERYDATE,HDESCRIPTION,
                     HMAPID,HPARENTMATID,HISRETURNCHECK,HROWTYPE,HROWID,HPARENTROWID,
                     HTAXCOMBINATION,HPRICEUNITID,HTaxRate,HPRICECOEFFICIENT,HSYSPRICE,HLIMITDOWNPRICE,
                     HDISCOUNTRATE,HISFREE,HSETTLETYPEID,HCHAGECONDITION,HSETTLECURRID,
                     HLOCALCURRID,HEXCHANGETYPEID,HISINCLUDEDTAX,HISPRICEEXCLUDETAX,
                     HTAXRATEID,HTaxRate_TAX,HTAXAMOUNT_TAX,HCOSTPERCENT,HCOSTAMOUNT,
                     HVAT,HSELLERWITHHOLDING,HBUYERWITHHOLDING,
                     HEXPUNIT,HEXPPERIOD,HProduceDate,HExpiryDate
                     ) values ('{oSub.HInterID}', '{oSub.HEntryID}', '{oSub.HMaterID}', '{oSub.HUnitID}', '{oSub.HQty}', '{oSub.HPrice}',
                     '{oSub.HMoney}', '{oSub.HTaxMoney}', '{oSub.HTaxPrice}', '{oSub.HWHID}', '{oSub.HRemark}',
                     '{oSub.HSourceInterID}', '{oSub.HSourceEntryID}', '{oSub.HSourceBillNo}', '{oSub.HSourceBillType}', '{oSub.HSeOrderInterID}', '{oSub.HSeOrderEntryID}', '{oSub.HSeOrderBillNo}',
                     '{oSub.HOWNERID}', '{oSub.HOWNERTYPEID}', '{oSub.HSETTLEORGID}',
                     '{oSub.HRelationQty}', '{oSub.HAuxPropID}', '{oSub.HBatchNO}', '{oSub.HMTONo}', '{oSub.HERPInterID}', '{oSub.HERPEntryID}',
                     '{oSub.HSOBILLTYPEID}', '{oSub.HRMTYPE}', '{oSub.HSTOCKUNITID}', '{oSub.HBASEUNITID}', '{oSub.HDELIVERYDATE}', '{oSub.HDESCRIPTION}',
                     '{oSub.HMAPID}', '{oSub.HPARENTMATID}', '{oSub.HISRETURNCHECK}', '{oSub.HROWTYPE}', '{oSub.HROWID}', '{oSub.HPARENTROWID}',
                     '{oSub.HTAXCOMBINATION}', '{oSub.HPRICEUNITID}', '{oSub.HTaxRate}', '{oSub.HPRICECOEFFICIENT}', '{oSub.HSYSPRICE}', '{oSub.HLIMITDOWNPRICE}',
                     '{oSub.HDISCOUNTRATE}', '{oSub.HISFREE}', '{oSub.HSETTLETYPEID}', '{oSub.HCHAGECONDITION}', '{oSub.HSETTLECURRID}',
                     '{oSub.HLOCALCURRID}', '{oSub.HEXCHANGETYPEID}', '{oSub.HISINCLUDEDTAX}', '{oSub.HISPRICEEXCLUDETAX}',
                     '{oSub.HTAXRATEID}', '{oSub.HTaxRate_TAX}', '{oSub.HTAXAMOUNT_TAX}', '{oSub.HCOSTPERCENT}', '{oSub.HCOSTAMOUNT}',
                     '{oSub.HVAT}', '{oSub.HSELLERWITHHOLDING}', '{oSub.HBUYERWITHHOLDING}',
                     '{oSub.HEXPUNIT}', '{oSub.HEXPPERIOD}', '{oSub.HProduceDate}', '{oSub.HExpiryDate}')";
                    LogService.Write("退货通知单子表同步:" + sql);
                    oCN.RunProc(sql);
                }
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "单据保存成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                LogService.Write("退货通知单同步异常,保存方法执行完成异常:" + e.Message.ToString());
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}