yxj
2024-07-12 97e4a58f895c8b020f7dcd736fd608000b6db18b
新增网页版单位换算列表所需调用方法
5个文件已修改
2个文件已添加
350 ■■■■■ 已修改文件
Model/Model.csproj 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Model/基础资料/基础资料/ClsGy_UnitConvertRate_Model.cs 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/基础资料/基础资料/Gy_UnitConvertRateController.cs 307 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/InvokeHelper.cs 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Web.config 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/WebAPI.csproj 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/WebAPI.csproj.user 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Model/Model.csproj
@@ -465,6 +465,7 @@
    <Compile Include="基础资料\基础资料\ClsGy_BarCodeCheckType_Model.cs" />
    <Compile Include="基础资料\基础资料\ClsGy_Item30JiTai_Model.cs" />
    <Compile Include="基础资料\基础资料\ClsGy_User_Model.cs" />
    <Compile Include="基础资料\基础资料\ClsGy_UnitConvertRate_Model.cs" />
    <Compile Include="基础资料\基础资料\ClsGy_Work_Model.cs" />
    <Compile Include="基础资料\基础资料\ClsXt_FastICSchemeMain_Model.cs" />
    <Compile Include="基础资料\基础资料\ClsXt_FastICSchemeSub_Model.cs" />
Model/»ù´¡×ÊÁÏ/»ù´¡×ÊÁÏ/ClsGy_UnitConvertRate_Model.cs
New file
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Model
{
    public class ClsGy_UnitConvertRate_Model : DBUtility.ClsGy_Base_Model
    {
        public string HBILLNO;              // varchar(30)
        public Int64 HMATERID;              // int --物料
        public Int64 HCURRENTUNITID;        // int --当前单位
        public Int64 HDESTUNITID;           // int --目标单位
        public string HCONVERTTYPE;         // varchar(20) --类型
        public double HCONVERTNUMERATOR;    // dec(23, 10) --分子
        public double HCONVERTDENOMINATOR;  // dec(23, 10) --分母
        public string HFORBIDSTATUS;        // varchar(10) --״̬
    }
}
WebAPI/Controllers/»ù´¡×ÊÁÏ/»ù´¡×ÊÁÏ/Gy_UnitConvertRateController.cs
New file
@@ -0,0 +1,307 @@
using DBUtility;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebAPI.Models;
namespace WebAPI.Controllers
{
    public class Gy_UnitConvertRateController : ApiController
    {
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
        const string ModCaption = "单位换算";
        public const string ModRightName = "Gy_UnitConvertRate";
        public const string ModRightNameDelete = ModRightName + "_Delete";  //删除
        public DataSet ds = new DataSet();
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
        #region å•位换算列表
        /// <summary>
        /// èŽ·å–å•ä½æ¢ç®—åˆ—è¡¨ä¿¡æ¯
        /// </summary>
        /// <returns></returns>
        [Route("Gy_UnitConvertRateController/GetGy_UnitConvertRateList_Json")]
        [HttpGet]
        public object GetGy_UnitConvertRateList_Json(string sWhere, string HMaker, string OperationType)
        {
            try
            {
                //判断权限  1为直接列表模块打开  2为从其他模块跳转打开列表
                if (OperationType == "1")
                {
                    //判断权限
                    if (!DBUtility.ClsPub.Security_Log(ModRightName, 1, false, HMaker))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "您没有该模块权限,请与管理员联系!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                //返回列表信息
                ds = oCn.RunProcReturn("select * from h_v_Gy_UnitConvertRateList where " + sWhere + " order by HItemID desc", "h_v_Gy_UnitConvertRateList");
                List<object> columnNameList = new List<object>();
                //添加列名
                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 = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "成功!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "查询列表信息失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å•位换算删除
        /// <summary>
        /// åˆ é™¤å•位换算
        /// </summary>
        /// <returns></returns>
        [Route("Gy_UnitConvertRateController/GetGy_UnitConvertRate_Delete_Json")]
        [HttpGet]
        public object GetGy_UnitConvertRate_Delete_Json(Int64 HItemID, string HMaker)
        {
            try
            {
                //判断权限
                if (!DBUtility.ClsPub.Security_Log(ModRightNameDelete, 1, false, HMaker))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "您没有该模块删除功能权限,请与管理员联系!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCn.BeginTran();
                //判断存在性
                ds = oCn.RunProcReturn("select HNumber,HName from Gy_UnitConvertRate with(nolock) where HItemID= " + HItemID.ToString(), "Gy_UnitConvertRate");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    oCn.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "未查询到该单位换算,请刷新数据后重新选择!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    oCn.RunProc("Delete from Gy_UnitConvertRate where HItemID= " + HItemID.ToString(), ref DBUtility.ClsPub.sExeReturnInfo);
                    //写入日志
                    DBUtility.ClsPub.Add_Log("", "删除单位换算,代码:" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HNumber"]) + ",名称:" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HName"]), HMaker);
                    oCn.Commit();
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除单位换算成功!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                oCn.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "删除单位换算失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å•位换算批量同步
        /// <summary>
        /// ä»Žé‡‘蝶云批量同步单位换算至本地表
        /// </summary>
        [Route("Gy_UnitConvertRateController/GetGy_UnitConvertRate_BatchSync_Json")]
        [HttpGet]
        public object GetGy_UnitConvertRate_BatchSync_Json()
        {
            try
            {
                //获取系统参数
                string sErrMsg = "";
                if (oSystemParameter.ShowBill(ref sErrMsg) == true)
                {
                    //系统参数是否为私有云模式,N为公有云模式,Y为私有云模式
                    //私有云模式,通过调用存储过程进行同步
                    if (oSystemParameter.omodel.WMS_CloudMode.ToUpper() == "Y")
                    {
                        ds = oCn.RunProcReturn("exec h_p_IFCLD_ERPDataToLocal_UnitConvertRate", "h_p_IFCLD_ERPDataToLocal_UnitConvertRate");
                        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
                        {
                            FormId = "BD_UNITCONVERTRATE",
                            FieldKeys = "FUNITCONVERTRATEID,FBILLNO,FMATERIALID,FUSEORGID,FCREATEORGID,FFORBIDSTATUS" +
                            ",FCURRENTUNITID,FDESTUNITID,FCONVERTTYPE,FCONVERTNUMERATOR,FCONVERTDENOMINATOR" +
                            ",FCREATORID,FCREATEDATE,FMODIFIERID,FMODIFYDATE,FAPPROVERID,FAPPROVEDATE,FFORBIDDERID,FFORBIDDATE",
                            FilterString = "",
                            OrderString = "",
                            TopRowCount = 0,
                            StartRow = 0,
                            Limit = 0
                        };
                        //查看 èŽ·å–æ•°æ®
                        var _result = InvokeHelper.Query("BD_UNITCONVERTRATE", JsonConvert.SerializeObject(json));
                        //反序列化
                        _result = _result.Replace("\"", "");
                        _result = _result.Replace("\n", "");
                        _result = _result.Replace(",[", "");
                        _result = _result.Replace("[", "");
                        string[] rows = _result.Split(new string[] { "]" }, StringSplitOptions.RemoveEmptyEntries); //以"]"分隔每一行并移除空行
                        string[,] arr = new string[rows.Length, rows[0].Split(',').Length]; //根据行和列数创建二维数组
                        for (int i = 0; i < rows.Length; i++) //遍历每一行
                        {
                            string[] cols = rows[i].Split(','); //以逗号分隔每一列
                            for (int j = 0; j < cols.Length; j++) //遍历每一列
                            {
                                arr[i, j] = cols[j]; //存入二维数组
                            }
                        }
                        //清空单位换算表数据
                        oCn.RunProc("Delete from Gy_UnitConvertRate", ref DBUtility.ClsPub.sExeReturnInfo);
                        //输出二维数组
                        for (int i = 0; i < arr.GetLength(0); i++)
                        {
                            var subData = new
                            {
                                HItemID = DBUtility.ClsPub.isLong(arr[i, 0]),
                                HNumber = "",
                                HName = "",
                                HShortNumber = "",
                                HParentID = 0,
                                HLevel = 1,
                                HEndFlag = 1,
                                HStopflag = arr[i, 5].ToString() == "B" ? 1 : 0,
                                HRemark = "CLD-ERP导入",
                                HUseFlag = "已使用",
                                HUSEORGID = DBUtility.ClsPub.isLong(arr[i, 3]),
                                HCREATEORGID = DBUtility.ClsPub.isLong(arr[i, 4]),
                                HBILLNO = DBUtility.ClsPub.isStrNull(arr[i, 1]),
                                HMATERID = DBUtility.ClsPub.isLong(arr[i, 2]),
                                HCURRENTUNITID = DBUtility.ClsPub.isLong(arr[i, 6]),
                                HDESTUNITID = DBUtility.ClsPub.isLong(arr[i, 7]),
                                HCONVERTTYPE = DBUtility.ClsPub.isStrNull(arr[i, 8]),
                                HCONVERTNUMERATOR = DBUtility.ClsPub.isDoule(arr[i, 9]),
                                HCONVERTDENOMINATOR = DBUtility.ClsPub.isDoule(arr[i, 10]),
                                HFORBIDSTATUS = DBUtility.ClsPub.isStrNull(arr[i, 5]),
                                HUnitID = DBUtility.ClsPub.isLong(arr[i, 2] == "0" ? arr[i, 6] : "-1"),
                                HMakeEmp = DBUtility.ClsPub.isStrNull(arr[i, 11]),
                                HMakeTime = DBUtility.ClsPub.isDate(arr[i, 12]),
                                HCheckEmp = DBUtility.ClsPub.isStrNull(arr[i, 15]),
                                HCheckTime = DBUtility.ClsPub.isDate(arr[i, 16]),
                                HModifyEmp = DBUtility.ClsPub.isStrNull(arr[i, 13]),
                                HModifyTime = DBUtility.ClsPub.isDate(arr[i, 14]),
                                HStopEmp = DBUtility.ClsPub.isStrNull(arr[i, 17]),
                                HStopTime = DBUtility.ClsPub.isDate(arr[i, 18]),
                            };
                            //写入单位换算表数据
                            oCn.RunProc("set identity_insert Gy_UnitConvertRate on", ref DBUtility.ClsPub.sExeReturnInfo);
                            string sql = $@"Insert into Gy_UnitConvertRate
                                    (HItemID,HNumber,HName,HShortNumber,HParentID,HLevel
                                    ,HEndFlag,HStopflag,HRemark,HUseFlag,HUSEORGID,HCREATEORGID
                                    ,HBILLNO,HMATERID,HCURRENTUNITID,HDESTUNITID,HCONVERTTYPE,HCONVERTNUMERATOR
                                    ,HCONVERTDENOMINATOR,HFORBIDSTATUS,HUnitID
                                    ,HMakeEmp,HMakeTime
                                    ,HCheckEmp,HCheckTime
                                    ,HModifyEmp,HModifyTime
                                    ,HStopEmp,HStopTime)
                                    Values({subData.HItemID},'{subData.HNumber}','{subData.HName}','{subData.HShortNumber}',{subData.HParentID},{subData.HLevel}
                                    ,{subData.HEndFlag},{subData.HStopflag},'{subData.HRemark}','{subData.HUseFlag}',{subData.HUSEORGID},{subData.HCREATEORGID}
                                    ,'{subData.HBILLNO}',{subData.HMATERID},{subData.HCURRENTUNITID},{subData.HDESTUNITID},{subData.HCONVERTTYPE},{subData.HCONVERTNUMERATOR}
                                    ,{subData.HCONVERTDENOMINATOR},'{subData.HFORBIDSTATUS}',{subData.HUnitID}
                                    ,'{subData.HMakeEmp}',case when '{subData.HMakeTime}' = '1900/1/1 0:00:00' then NULL else '{subData.HMakeTime}' end
                                    ,'{subData.HCheckEmp}',case when '{subData.HCheckTime}' = '1900/1/1 0:00:00' then NULL else '{subData.HCheckTime}' end
                                    ,'{subData.HModifyEmp}',case when '{subData.HModifyTime}' = '1900/1/1 0:00:00' then NULL else '{subData.HModifyTime}' end
                                    ,'{subData.HStopEmp}',case when '{subData.HStopTime}' = '1900/1/1 0:00:00' then NULL else '{subData.HStopTime}' end)";
                            oCn.RunProc(sql.Replace("\r\n", ""));
                            oCn.RunProc("set identity_insert Gy_UnitConvertRate off", ref DBUtility.ClsPub.sExeReturnInfo);
                        }
                        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
    }
}
WebAPI/InvokeHelper.cs
@@ -16,9 +16,17 @@
        /// </summary>
        public static string Login()
        {
            var dbId = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "DbId");
            var useName = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "UserName");
            var pwd = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "PassWord");
            //从C盘配置文件获取 CLOUD网址、账套信息、登录用户、登录密码
            Pub_Class.ClsPub.GetCLOUDLoginInfo(ref Pub_Class.ClsPub.sExeReturnInfo);
            var useName = Pub_Class.ClsPub.sCLOUDUseName;
            var pwd = Pub_Class.ClsPub.sCLOUDPsd;
            var dbId = Pub_Class.ClsPub.sCLOUDAcc;
            CloudUrl = Pub_Class.ClsPub.sCLOUDUrl;
            //原从Config/kdapi.config模块中获取    20240712屏蔽
            //var dbId = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "DbId");
            //var useName = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "UserName");
            //var pwd = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "PassWord");
            HttpClient httpClient = new HttpClient();
            httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc");
@@ -215,6 +223,9 @@
            return httpClient.SyncRequest();
        }
        /// <summary>
        /// å•据查询
        /// </summary>
        public static string Query(string formId, string content)
        {
            HttpClient httpClient = new HttpClient();
WebAPI/Web.config
@@ -22,7 +22,7 @@
        <!--<add key="FileIP" value="http://localhost:8082/LuBaoAPI"/>-->
        <!--<add key="FileIP" value="http://localhost:8080/" />-->
        <!--<add key="sUrl" value="http://183.129.128.86:9090/WEBS-WMSTest/WebService1.asmx"/>    -->
        <!--<add key="sUrl" value="http://192.168.0.81/WEBS-WMS/WebService1.asmx"/>   é¢œå°å¼æœº-->
        <add key="sUrl" value="http://192.168.0.81/WEBS-WMS/WebService1.asmx"/> <!--颜台式机-->
        <!--<add key="sUrl" value="http://60.190.4.42:9003/WebService/WebService1.asmx" /> å¤å®-->
        <!--<add key="sUrl" value="http://60.190.4.42:9003/WebService/WebService1.asmx" /> -->
        <!--<add key="sUrl" value="http://10.10.130.181/WEBS-WMS/WebService1.asmx"/>    åšæ—¥ç§‘技-->
@@ -35,7 +35,7 @@
        <!--<add key="sUrl" value="http://47.96.97.237/WEBS-WMS/WebService1.asmx"/> -->    <!--测试服务器-->
        <!--<add key="surl" value="http://localhost:8082/webs/webservice1.asmx"/>    æœ¬åœ°-->
        <!--<add key="sUrl" value="http://192.168.110.57:81/WEBS/WebService1.asmx"/>-->    <!--陈雯静本地配置-->
        <add key="surl" value="http://localhost/webs-web/webservice1.asmx"/>    <!--翁涛涛本地配置-->
        <!--<add key="surl" value="http://localhost/webs-web/webservice1.asmx"/>-->    <!--翁涛涛本地配置-->
        <!--<add key="sUrl" value="http://192.168.1.57:8082/WEBS-WMS/WebService1.asmx"/>九菱-->
        <!--<add key="sUrl" value="http://61.130.182.102:18181/WEBSCS/WebService1.asmx"/>--><!--斯莫尔-->
        
WebAPI/WebAPI.csproj
@@ -572,6 +572,7 @@
    <Compile Include="Controllers\基础资料\基础资料\Gy_TaxRateBillController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Gy_WorkController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Gy_WorkStationBillController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Gy_UnitConvertRateController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Xt_CheckFlowBillController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Xt_CheckFlowProgressBillController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Xt_CheckItemBillController.cs" />
WebAPI/WebAPI.csproj.user
@@ -9,7 +9,7 @@
    <WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected>
    <NameOfLastUsedPublishProfile>FolderProfile</NameOfLastUsedPublishProfile>
    <NameOfLastUsedPublishProfile>D:\Git\houduan\WebAPI\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
    <NameOfLastUsedPublishProfile>C:\Users\86130\Desktop\智云迈思\MES-WEB-API\WebAPI\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
    <NameOfLastUsedPublishProfile>D:\GIT仓库\MES-WEB-API\WebAPI\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
    <LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
    <UseIISExpress>true</UseIISExpress>
    <Use64BitIISExpress />