|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- using System;
- using Learun.Util;
- using System.Data;
- using Learun.Application.TwoDevelopment.PersonnelManagement;
- using System.Web.Mvc;
- using System.Collections.Generic;
- using System.Linq;
- using Learun.Application.Organization;
- using Learun.Application.TwoDevelopment.LR_Desktop;
- using Learun.Util.Operat;
- using Newtonsoft.Json;
-
- namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 力软敏捷开发框架
- /// Copyright (c) 2013-2018 上海力软信息技术有限公司
- /// 创 建:超级管理员
- /// 日 期:2019-09-24 15:32
- /// 描 述:内控管理
- /// </summary>
- public class MP_ManagementPlanController : MvcControllerBase
- {
- private WeChatConfigIBLL weChatConfigIbll = new WeChatConfigBLL();
- private WeChatTempletIBLL weChatTempletIbll = new WeChatTempletBLL();
- private UserIBLL userIBLL=new UserBLL();
- private MP_ManagementPlanIBLL mP_ManagementPlanIBLL = new MP_ManagementPlanBLL();
-
- #region 视图功能
-
- /// <summary>
- /// 主页面
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Index()
- {
- return View();
- }
- /// <summary>
- /// 管理员页面
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult IndexManagement()
- {
- return View();
- }
- /// <summary>
- /// 提交材料页面
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult IndexChildren()
- {
- return View();
- }
- /// <summary>
- /// 表单页
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Form()
- {
- return View();
- }
- /// <summary>
- /// 表单页
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult UploadForm()
- {
- return View();
- }
-
- #endregion
-
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表数据
- /// <summary>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetPageList(string pagination, string queryJson)
- {
- Pagination paginationobj = pagination.ToObject<Pagination>();
- var data = mP_ManagementPlanIBLL.GetPageList(paginationobj, queryJson);
- var jsonData = new
- {
- rows = data,
- total = paginationobj.total,
- page = paginationobj.page,
- records = paginationobj.records
- };
- return Success(jsonData);
- }
- /// <summary>
- /// 获取表单数据
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetFormData(string keyValue)
- {
- var MP_ManageMentPlanData = mP_ManagementPlanIBLL.GetMP_ManageMentPlanEntity(keyValue);
- var jsonData = new
- {
- MP_ManageMentPlan = MP_ManageMentPlanData,
- };
- return Success(jsonData);
- }
-
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetAcademicYear()
- {
- var data = WebHelper.GenerateNearByAcademicTwo();
- return Success(data);
- }
-
-
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult DeleteForm(string keyValue)
- {
- mP_ManagementPlanIBLL.DeleteEntity(keyValue);
- return Success("删除成功!");
- }
- /// <summary>
- /// 合格/不合格
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult Qqualified(string keyValue, bool status)
- {
- var entity = mP_ManagementPlanIBLL.GetMP_ManageMentPlanEntity(keyValue);
- entity.MPConclusion = status?1:0;
- mP_ManagementPlanIBLL.SaveEntity(keyValue, entity);
- return Success("修改成功!");
- }
-
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveForm(string keyValue, string strEntity)
- {
- MP_ManageMentPlanEntity entity = strEntity.ToObject<MP_ManageMentPlanEntity>();
- entity.MPType = 0;
- mP_ManagementPlanIBLL.SaveEntity(keyValue, entity);
- return Success("保存成功!");
- }
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult UploadForm(string keyValue, string strEntity)
- {
- MP_ManageMentPlanEntity entity = strEntity.ToObject<MP_ManageMentPlanEntity>();
- if (!string.IsNullOrEmpty(keyValue))
- {
- var entity2 = mP_ManagementPlanIBLL.GetMP_ManageMentPlanEntity(keyValue);
- if (!string.IsNullOrEmpty(entity.MPFileTwo))
- {
- entity.MPStatus = 0;//已提交
- entity.MPUploadTimes = $"{DateTime.Now.ToString()}, {entity2.MPUploadTimes}";
- entity.SUpdateTime = entity2.SUpdateTime + 1;
- }
-
- }
- else
- {
- entity.Create();
- if (!string.IsNullOrEmpty(entity.MPFileTwo))
- {
- entity.MPStatus = 0;//已提交
- entity.MPUploadTimes = DateTime.Now.ToString();
- entity.SUpdateTime = 1;
- entity.MPType = 0;
- }
-
- }
-
- entity.MPUploaderTwo = LoginUserInfo.Get().userId;
- mP_ManagementPlanIBLL.SaveEntity(keyValue, entity);
- return Success("保存成功!");
- }
-
- public void PushWeixin(string MPId)
- {
- var title = "";
- //获取内控模板信息
- var mpEntity = mP_ManagementPlanIBLL.GetMP_ManageMentPlanEntity(MPId);
- //根据部门获取所有需要推送的人员
- var UserList = new List<UserEntity>();
- if (mpEntity != null)
- {
- var departmentList = mpEntity.MPDepartment.Split(',').ToList();
- foreach (var departmentId in departmentList)
- {
- var entityList=userIBLL.GetListByDepartmentId(departmentId);
- if (entityList.Count>0)
- {
- UserList.Union(entityList);
- }
- }
-
-
- switch (mpEntity.MPType)
- {
- case 0:
- title = "您有内控检查材料需要上传,请查看";
- break;
- case 1:
- title = "您有绩效测试材料需要上传,请查看";
- break;
- case 2:
- title = "您有质量测试材料需要上传,请查看";
- break;
- }
- }
-
-
-
-
- var WeChatConfigentity = weChatConfigIbll.GetEnableEntity();
- string appid = WeChatConfigentity.APPId;
- string secret = WeChatConfigentity.secret;
- var wechatemplete = weChatTempletIbll.GetWeChatTemplateEntityByCodeConfigId(WeChatConfigentity.ID, "task");
- string weixintaskurl = wechatemplete.TUrl;
- string weixintasktempid = wechatemplete.TempId;
- var responsejson = Util.HttpMethods.HttpGet("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret);
-
- OperateLogModel operateLogModel = new OperateLogModel();
- operateLogModel.title = title;
- operateLogModel.type = OperationType.Other;
- operateLogModel.url = "NoticeController";
- operateLogModel.sourceObjectId = "002";
- operateLogModel.sourceContentJson = responsejson;
- OperatorHelper.Instance.WriteOperateLog(operateLogModel);
-
- foreach (UserEntity userinfo in UserList)
- {
- if (userinfo != null && !string.IsNullOrEmpty(userinfo.OpenIdForWeixin))
- {
- //执行推送任务
- if (!string.IsNullOrEmpty(appid) && !string.IsNullOrEmpty(secret) && !string.IsNullOrEmpty(weixintaskurl) && !string.IsNullOrEmpty(weixintasktempid))
- {
- if (!string.IsNullOrEmpty(responsejson))
- {
- var weixintokenobj = JsonConvert.DeserializeObject<dynamic>(responsejson);
- if (string.IsNullOrEmpty(weixintokenobj.errcode))
- {
- string access_token = weixintokenobj.access_token;
- string jsondata = "{\"touser\":\"" + userinfo.OpenIdForWeixin + "\"," +
- "\"template_id\":\"" + weixintasktempid + "\"," +
- "\"url\":\"" + weixintaskurl + "\"," +
- "\"data\":{" +
- "\"first\": {\"value\":\"您有新的未读通知公告\",\"color\":\"#173177\"}," +
- "\"keyword1\":{\"value\":\"未读通知公告\",\"color\":\"#173177\"}," +
- "\"keyword2\": {\"value\":\"" + title + "\",\"color\":\"#173177\"}," +
- "\"keyword3\": {\"value\":\"待查看\",\"color\":\"#173177\"}," +
- "\"keyword4\": {\"value\":\"您有新的未读通知公告【" + title + "】\",\"color\":\"#173177\"}" +
- "}" +
- "}";
- string pushresult = Util.HttpMethods.HttpPost("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + access_token, jsondata);
-
- operateLogModel.title = title;
- operateLogModel.type = OperationType.Other;
- operateLogModel.url = "NoticeController";
- operateLogModel.sourceObjectId = "002";
- operateLogModel.sourceContentJson = pushresult;
- OperatorHelper.Instance.WriteOperateLog(operateLogModel);
- }
- }
- }
- }
- }
- }
-
- #endregion
-
- }
- }
|