diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Organization/Company/CompanyEntity.cs b/Learun.Framework.Ultimate V7/Learun.Application.Organization/Company/CompanyEntity.cs index 22fb1263d..35c67d32b 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Organization/Company/CompanyEntity.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Organization/Company/CompanyEntity.cs @@ -214,6 +214,11 @@ namespace Learun.Application.Organization /// [Column("F_EnrollmentInformation")] public string F_EnrollmentInformation { get; set; } + /// + /// 统一社会信用代码 + /// + [Column("F_USCREDITCODE")] + public string F_USCreditCode { get; set; } #endregion #region 扩展操作 diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/DataCollectionController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/DataCollectionController.cs new file mode 100644 index 000000000..192146a4e --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/DataCollectionController.cs @@ -0,0 +1,41 @@ +using Learun.Util; +using System.Data; +using Learun.Application.TwoDevelopment.LR_Desktop; +using System.Web.Mvc; +using System.Collections.Generic; + +namespace Learun.Application.Web.Areas.LR_Desktop.Controllers +{ + /// + /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架 + /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司 + /// 创 建:超级管理员 + /// 日 期:2021-06-22 10:04 + /// 描 述:计算项目管理 + /// + public class DataCollectionController : MvcControllerBase + { + private DataCollectionIBLL dataCollectionIBLL = new DataCollectionBLL(); + + #region 视图功能 + + /// + /// 主页面 + /// + /// + [HttpGet] + public ActionResult Index() + { + return View(); + } + #endregion + + [HttpPost] + [AjaxOnly] + public ActionResult SyncCompany() + { + dataCollectionIBLL.SaveXqjbsj(); + return Success("操作成功"); + } + } +} diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/DataCollection/Index.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/DataCollection/Index.cshtml new file mode 100644 index 000000000..839db0da5 --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/DataCollection/Index.cshtml @@ -0,0 +1,28 @@ +@{ + ViewBag.Title = "智慧大脑数据采集"; + Layout = "~/Views/Shared/_Index.cshtml"; +} +
+
+
+
+ + @*
+
+ +
+ +
*@ +
+
+
+
+
+@Html.AppendJsFile("/Areas/LR_Desktop/Views/DataCollection/Index.js") diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/DataCollection/Index.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/DataCollection/Index.js new file mode 100644 index 000000000..5c40dc08f --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/DataCollection/Index.js @@ -0,0 +1,48 @@ +/* * 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架(http://www.learun.cn) + * Copyright (c) 2013-2020 力软信息技术(苏州)有限公司 + * 创建人:超级管理员 + * 日 期:2021-06-22 10:04 + * 描 述:计算项目管理 + */ +var refreshGirdData; +var bootstrap = function ($, learun) { + "use strict"; + var page = { + init: function () { + page.initGird(); + page.bind(); + }, + bind: function () { + $('#multiple_condition_query').lrMultipleQuery(function (queryJson) { + page.search(queryJson); + }, 220, 400); + $('#Type').lrDataItemSelect({ code: 'projectType' }); + // 刷新 + $('#lr_refresh').on('click', function () { + location.reload(); + }); + //校区基础数据 + $('#lr_company').on('click', function () { + learun.layerConfirm('是否确认推送校区基础数据!', function (res) { + if (res) { + learun.deleteForm(top.$.rootUrl + '/LR_Desktop/DataCollection/SyncCompany', function () { + refreshGirdData(); + }); + } + }); + }); + + }, + // 初始化列表 + initGird: function () { + + }, + search: function (param) { + + } + }; + refreshGirdData = function () { + + }; + page.init(); +} diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OrganizationModule/Views/Company/Form.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OrganizationModule/Views/Company/Form.cshtml index 49eb7e279..6a78c3355 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OrganizationModule/Views/Company/Form.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OrganizationModule/Views/Company/Form.cshtml @@ -20,6 +20,10 @@
+
统一社会信用代码*
+ +
+
成立时间
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj index c3d8d2f62..66e8ba38a 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj @@ -405,6 +405,7 @@ + @@ -1453,6 +1454,7 @@ + @@ -7693,6 +7695,7 @@ + diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config b/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config index 324830c7c..847cc2703 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config @@ -104,14 +104,12 @@ - - - + - + - + diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/DataCollection/DataCollectionBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/DataCollection/DataCollectionBLL.cs index 565683b97..da801f4b5 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/DataCollection/DataCollectionBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/DataCollection/DataCollectionBLL.cs @@ -42,9 +42,27 @@ namespace Learun.Application.TwoDevelopment.LR_Desktop // } // } //} - - #endregion + #endregion + public void SaveXqjbsj() + { + try + { + dataCollectionService.SaveXqjbsj(); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } + } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/DataCollection/DataCollectionIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/DataCollection/DataCollectionIBLL.cs index 693d86b20..95ffab4d5 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/DataCollection/DataCollectionIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/DataCollection/DataCollectionIBLL.cs @@ -4,24 +4,8 @@ using System.Collections.Generic; namespace Learun.Application.TwoDevelopment.LR_Desktop { - /// - /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架 - /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司 - /// 创 建:超级管理员 - /// 日 期:2021-06-22 10:04 - /// 描 述:计算项目管理 - /// public interface DataCollectionIBLL { - #region 获取数据 - - ///// - ///// 获取页面显示列表数据 - ///// - ///// 查询参数 - ///// - //IEnumerable GetPageList(Pagination pagination, string queryJson); - #endregion - + void SaveXqjbsj(); } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/DataCollection/DataCollectionService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/DataCollection/DataCollectionService.cs index 759a7fae5..797a29c0b 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/DataCollection/DataCollectionService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/DataCollection/DataCollectionService.cs @@ -5,20 +5,21 @@ using System; using System.Collections.Generic; using System.Configuration; using System.Data; +using System.Linq; using System.Text; using Newtonsoft.Json; +using Learun.Application.Organization; +using Learun.Application.Base.SystemModule; +using Learun.Cache.Redis; namespace Learun.Application.TwoDevelopment.LR_Desktop { /// - /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架 - /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司 - /// 创 建:超级管理员 - /// 日 期:2021-06-22 10:04 - /// 描 述:计算项目管理 + /// 智慧大脑数据采集 /// public class DataCollectionService : RepositoryFactory { + CacheByRedis _redis = new CacheByRedis(); #region 获取数据 //接口地址 private static string InsUrl = ConfigurationManager.AppSettings["CYInsUrl"]; @@ -28,57 +29,164 @@ namespace Learun.Application.TwoDevelopment.LR_Desktop private static string username = ConfigurationManager.AppSettings["CYUsername"]; //密码 private static string password = ConfigurationManager.AppSettings["CYPassword"]; + //数据采集接口地址 + private static string saveIncrUrl = InsUrl + "/prod-api/api/web/collect/interface/saveIncrData"; + ////令牌 + //private string access_token; + ////刷新密钥 + //private string client_secret; + ////刷新令牌 + //private string refresh_token; - //令牌 - private string access_token; - //刷新密钥 - private string client_secret; - //刷新令牌 - private string refresh_token; - - private DataCollectionService() + public DataCollectionService() + { + try + { + var refresh_token = _redis.Read("refresh_token"); + var access_token = _redis.Read("access_token"); + if (string.IsNullOrEmpty(refresh_token) || string.IsNullOrEmpty(_redis.Read("access_token"))) + { + //用户授权 + login(); + } + else if (!string.IsNullOrEmpty(refresh_token) && string.IsNullOrEmpty(_redis.Read("access_token"))) + { + //刷新token + refresh(); + } + } + catch (ExceptionEx ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } + /// + /// 用户授权 + /// + private void login() { - //用户授权 - var login_url = InsUrl + "/prod-api/api/web/collect/oauth2/login"; - var login_param = "{\"grant_type\":" + "" + ",\"client_id\":\"" + client_id + "\",\"username\":\"" + username + "\",\"password\":\"" + password + "\"}"; - var login_res_str = HttpMethods.Post(login_url, login_param); + var login_url = InsUrl + "/prod-api/api/web/collect/oauth2/login?grant_type=password&client_id=" + client_id + "&username=" + username + "&password=" + password; + var login_res_str = HttpMethods.Get(login_url); var login_res = JsonConvert.DeserializeObject(login_res_str); var login_data = login_res.data; - access_token = ((dynamic)login_data).access_token; + _redis.Write($"access_token", ((dynamic)login_data)?.access_token, TimeSpan.FromSeconds(250)); + _redis.Write($"client_secret", ((dynamic)login_data)?.client_secret, TimeSpan.FromSeconds(170000)); + _redis.Write($"refresh_token", ((dynamic)login_data)?.refresh_token, TimeSpan.FromSeconds(250)); + } + /// + /// 刷新token + /// + private void refresh() + { + var client_secret = (_redis.Read("client_secret"))?.Replace("\"",""); + var refresh_token = (_redis.Read("refresh_token"))?.Replace("\"", ""); + var refresh_url = + InsUrl + "/prod-api/api/web/collect/oauth2/refresh?grant_type=refresh_token&client_id=" + + client_id + "&client_secret=" + client_secret + "&refresh_token=" + refresh_token; + var refresh_res_str = HttpMethods.Get(refresh_url); + var refresh_res = JsonConvert.DeserializeObject(refresh_res_str); + if (refresh_res == null || ((dynamic)refresh_res)?.code != 200) + { + _redis.Write($"refresh_token", "", TimeSpan.FromSeconds(60)); + //接口返回失败重新调用授权接口 + login(); + return; + } + _redis.Write($"access_token", ((dynamic)refresh_res)?.access_token, TimeSpan.FromSeconds(250)); + _redis.Write($"refresh_token", ((dynamic)refresh_res)?.refresh_token, TimeSpan.FromSeconds(250)); + } + /// + /// 校区基础数据 + /// + public void SaveXqjbsj() + { + try + { + var connect = (_redis.Read("access_token")).Replace("\"", ""); + //校区信息 + var entity = this.BaseRepository().FindList(x => x.F_DeleteMark == 0 && x.F_EnabledMark == 1).FirstOrDefault(); + var pro = entity.F_ProvinceId.Substring(0, 2); + //区域信息 + var area = this.BaseRepository() + .FindList($"select * from LR_Base_Area where F_AreaId like '{pro}%'"); + + var empCount = this.BaseRepository("CollegeMIS").FindObject($"select count(1) from EmpInfo where CheckMark = 1"); + var stuCount = this.BaseRepository("CollegeMIS").FindObject($"select count(1) from StuInfoBasic where CheckMark = 1"); + ParamModel paramModel = new ParamModel(); + paramModel.dataObjName = "ods_xqjcsj"; + var list = new List(); + + var param = new + { + xygkjcsjid = entity.F_CompanyId, + provincejgbm = entity.F_ProvinceId, + provincejgmc = area.Where(x => x.F_AreaId == entity.F_ProvinceId).FirstOrDefault().F_AreaName, + cityjgbm = entity.F_CityId, + cityjgmc = area.Where(x => x.F_AreaId == entity.F_CityId).FirstOrDefault().F_AreaName, + countyjgbm = entity.F_CountyId, + countyjgmc = area.Where(x => x.F_AreaId == entity.F_CountyId).FirstOrDefault().F_AreaName, + //统一社会信用代码 + xxjgdm = entity.F_USCreditCode, + xxjgmc = entity.F_FullName, + xqbh = entity.F_EnCode, + xqmc = entity.F_FullName, + xqjc = entity.F_SortCode, + xqszdxzqh = "", + xqdz = "", + xqyzbm = "", + xqlxdh = "", + xqfzr = "", + //校区教职工总数 + xqjzgzs = empCount, + //校区学生总数 + xqxszs = stuCount, + xqclrq = "", + sjcjsj = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + }; + list.Add(param); + paramModel.fileds = list; + var json = JsonConvert.SerializeObject(paramModel); + var res = HttpMethods.HttpPostConnect(saveIncrUrl, json, connect); + } + catch (ExceptionEx ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } } - ///// - ///// 获取CalculateProject表实体数据 - ///// - ///// 主键 - ///// - //public CalculateProjectEntity GetCalculateProjectEntity(string keyValue) - //{ - // try - // { - // return this.BaseRepository("CollegeMIS").FindEntity(keyValue); - // } - // catch (Exception ex) - // { - // if (ex is ExceptionEx) - // { - // throw; - // } - // else - // { - // throw ExceptionEx.ThrowServiceException(ex); - // } - // } - //} #endregion + #region MyRegion + public class InsResult { public int code { get; set; } public string msg { get; set; } public object data { get; set; } } + + public class ParamModel + { + public string dataObjName { get; set; } + public List fileds { get; set; } + } + + #endregion } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/HttpMethods.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/HttpMethods.cs index 33403c314..a6d106cbc 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/HttpMethods.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/HttpMethods.cs @@ -191,7 +191,7 @@ namespace Learun.Util HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.Method = "POST"; req.ContentType = "application/json;charset=UTF-8"; - req.Headers.Add("Connect", connect); + req.Headers.Add("connect", connect); byte[] data = Encoding.UTF8.GetBytes(json);//把字符串转换为字节