using dccdc.BLL; using dccdc.Models; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; using System.Web.Mvc; using Newtonsoft.Json; using System.Data; using static dccdc.Controllers.DictionariesController; using System.Net; using System.Reflection; using Aliyun.Acs.Core.Profile; using Aliyun.Acs.Core.Exceptions; using Aliyun.Acs.Dysmsapi.Model.V20170525; using Aliyun.Acs.Core; using System.Collections; using dccdc.DAL; using System.Web.UI; using System.Text; using System.Data.SqlClient; using System.Configuration; using System.Web.Configuration; using Newtonsoft.Json.Linq; using Deepleo.Weixin.SDK; using System.Web.Helpers; using ZWL.Common; using System.Security.Cryptography; namespace dccdc.Controllers { public class InfectionController : Controller { Random random = new Random(); #region 微信--信息录入处理 /// /// 获取全部信息 /// /// [AllowAnonymous] public JsonResult GetAllData_OpenUserInfo() { return Json(new BLL.InfectionOpenUserInfoBll().GetAllDataList()); } /// /// 根据身份证号码获取信息 /// /// /// [AllowAnonymous] public JsonResult GetDataByIdent_OpenUserInfo(string ident) { return Json(new BLL.InfectionOpenUserInfoBll().GetDataListByIdent(ident)); } /// /// 查询未审核的数据 /// /// public JsonResult GetNotTypeData_OpenUserInfo() { return Json(new BLL.InfectionOpenUserInfoBll().GetDataListNotType()); } /// /// 保存数据和图片 /// /// /// /// [AllowAnonymous] public string SaveData_OpenUserInfo(InfectionOpenUserInfoModel model) { log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(Newtonsoft.Json.JsonConvert.SerializeObject(model)); var yzmbll = new BLL.DuanXinYanZhengBll(); if (string.IsNullOrEmpty(model.yzmid)) { return "手机验证码不正确!"; } var yzm = yzmbll.getYZMById(model.yzmid); if (yzm == null) { return "手机验证码不正确!"; } if (yzm.ShouJiHao != model.phone) { return "手机号码和获取验证码的手机号码不一致!"; } if ((DateTime.Now - yzm.sendtime).TotalMinutes > yzm.YanZhengYouXiaoQi) { return "验证码已经超过有效期!"; } if (yzm.state != 0) { return "验证码已经使用不能重复验证!"; } if (yzm.smscode != model.yzm) { return "手机验证码不正确!"; } if (model.referee != null && model.referee != "") { if (new BLL.InfectionOpenUserInfoBll().JudgementCode(model.referee).Equals("False")) { return "推荐码不正确!"; } } string userid = string.Empty; try { userid = Session["InfectionUserID"].ToString(); } catch { userid = string.Empty; } if (new InfectionOpenUserBll().checkUserIdent(model.ident, userid) > 0) { return "身份证已被绑定!"; } string address = string.Empty; string returnValue = string.Empty; log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("tupian===================="); if (model.license == "1") { if (Request.Files.Count != 0) { string s = Request.Files.GetType().ToString(); string path = string.Empty; try { path = Server.MapPath("~/photo/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string specificDate = DateTime.Now.ToString("yyyyMMdd").ToString(); path += specificDate + "/"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } address = DateTime.Now.ToString("HHmmss") + "-" + Guid.NewGuid().ToString() + ".jpg"; path += address; Request.Files[0].SaveAs(path); address = "/photo/" + specificDate + "/" + address; } catch { returnValue = "图片保存失败!"; } } } else { address = "false"; } int user_id; try { user_id = int.Parse(Session["InfectionUserID"].ToString()); } catch { return "找不到个人信息!"; } model.user_id = user_id; model.type = 0; model.license = address; model.recommend = RecommendNumber(); //推荐码已存在 while (new BLL.InfectionOpenUserInfoBll().JudgementCode(model.recommend) == "True") { model.recommend = RecommendNumber(); } model.create_time = DateTime.Now.ToString(); log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("xiugai===================="); var modelUser = new InfectionOpenUserBll().GetDataByID(model.user_id.ToString()); string openid = modelUser.openid; string recommendold = modelUser.recommendold; if (!string.IsNullOrEmpty(recommendold)) { model.recommend = recommendold; } List models = new BLL.InfectionOpenUserInfoBll().GetDataListByUserID(user_id); if (models != null && models.Count > 0) { if (string.IsNullOrEmpty(returnValue)) { if (new BLL.InfectionOpenUserInfoBll().ModifyDataByUserID(model)) { var data = new { touser = openid, template_id = "Yv4y0EqsdEDUjvWZOELdITMjQ77Bv6gZf_aJX3xcatg", data = new { first = new { value = "您好,您已成功上传个人信息,请耐心等待审核通过!", color = "#173177" }, keyword1 = new { value = model.name, color = "#173177" }, keyword2 = new { value = "个人信息上传", color = "#173177" }, keyword3 = new { value = DateTime.Now.ToString("yyyy-MM-dd"), color = "#173177" }, //remark = new { value = "点击完善个人信息。", color = "#173177" }, } }; WebClient wc = new WebClient(); wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + Common.Global.getAccessTokenInfection.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data))); return "修改成功!"; } else { return "修改失败!"; } } else { return returnValue; } } else { if (string.IsNullOrEmpty(returnValue)) { if (new BLL.InfectionOpenUserInfoBll().SaveData(model)) { var data = new { touser = openid, template_id = "Yv4y0EqsdEDUjvWZOELdITMjQ77Bv6gZf_aJX3xcatg", data = new { first = new { value = "您好,您已成功上传个人信息,请耐心等待审核通过!", color = "#173177" }, keyword1 = new { value = model.name, color = "#173177" }, keyword2 = new { value = "个人信息上传", color = "#173177" }, keyword3 = new { value = DateTime.Now.ToString("yyyy-MM-dd"), color = "#173177" }, //remark = new { value = "点击完善个人信息。", color = "#173177" }, } }; WebClient wc = new WebClient(); wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + Common.Global.getAccessTokenInfection.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data))); return "保存成功!"; } else { return "保存失败!"; } } else { return returnValue; } } } /// /// 根据userID修改数据 /// /// /// /// [AllowAnonymous] public JsonResult ModifyDataByID_OpenUserInfo(InfectionOpenUserInfoModel model) { return Json(new BLL.InfectionOpenUserInfoBll().ModifyDataByUserID(model)); } /// /// 根据姓名、电话、身份证获取数据 /// /// /// /// /// [AllowAnonymous] public JsonResult GetDataListByNamePhoneIdent_OpenUserInfo(string name, string phone, string ident) { return Json(new BLL.InfectionOpenUserInfoBll().GetDataListByNamePhoneIdent(name, phone, ident)); } /// /// 根据ID获取所有的数据 /// /// /// [AllowAnonymous] public JsonResult GetDataListByID_OpenUserInfo(string ID) { return Json(new BLL.InfectionOpenUserInfoBll().GetDataListByID(ID)); } /// /// 根据user_id获取数据 /// /// /// [AllowAnonymous] public JsonResult GetDataListByUserID_OpenUserInfo() { int user_id; try { user_id = int.Parse(Session["InfectionUserID"].ToString()); } catch { return Json("找不到个人信息!"); } return Json(new BLL.InfectionOpenUserInfoBll().GetDataListByUserID(user_id)); } /// /// 信息审核 /// /// /// /// /// [AllowAnonymous] public string AuditInformation_OpenUserInfo(string id, string type, string cancel_reason) { InfectionOpenUserModel userModel = new BLL.InfectionOpenUserBll().GetDataByID(Session["InfectionUserID"].ToString()); InfectionOpenUserInfoModel infoModel = new InfectionOpenUserInfoBll().findById(int.Parse(id)); if (userModel.oa_id.ToString() != "" && userModel.oa_id > 0) { InfectionOpenUserModel OpenUserInfo = new InfectionOpenUserBll().GetDataByID(infoModel.user_id.ToString()); string pass_time = DateTime.Now.ToString(); string openid = OpenUserInfo.openid; string returnvalue = new BLL.InfectionOpenUserInfoBll().AuditInformation(id, type, cancel_reason, userModel.oa_id.ToString(), pass_time); if (returnvalue.Equals("审核成功!")) { var data = new { touser = openid, template_id = "bbpoBaop3Qs5tYAjvokYDqr9bL2SQzp5g5mbGB-m0uo", data = new { first = new { value = "您好,您的信息已通过审核,请等待进行问卷调查!", color = "#173177" }, keyword1 = new { value = infoModel.name, color = "#173177" }, keyword2 = new { value = infoModel.ident, color = "#173177" }, keyword3 = new { value = infoModel.phone, color = "#173177" }, remark = new { value = "您好,恭喜您已通过健康E路系统审核,请耐心等待进行问卷调查,我们已经为您准备好了丰厚的红包奖励和免费健康体检大礼包。", color = "#173177" }, } }; WebClient wc = new WebClient(); wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + Common.Global.getAccessTokenInfection.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data))); } if (returnvalue.Equals("驳回成功!")) { var data = new { touser = openid, template_id = "XBUW_-9IUlj7KO3DJQ-pvcOipqCrWajQDZN3nw-61aI", url = "http://oa.dcqcdc.com/dccdc/Infection/personInfoEntering", data = new { first = new { value = "您好,您的申请未通过,请重新录入信息进行审核!", color = "#173177" }, keyword1 = new { value = pass_time, color = "#173177" }, keyword2 = new { value = "信息不完善", color = "#173177" }, //keyword3 = new { value = model.ADate.ToString("yyyy-MM-dd"), color = "#173177" }, remark = new { value = "对不起,您的信息未能通过健康E路系统审核,请核对好姓名、身份证件、驾驶证等信息后再次提交,谢谢。", color = "#173177" }, } }; WebClient wc = new WebClient(); wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + Common.Global.getAccessTokenInfection.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data))); } return returnvalue; } else { return "请绑定OA用户!"; } } /// /// 获取所有用户信息 /// /// [AllowAnonymous] public JsonResult GetAllHangIntheAirQuestion_OpenUserInfo(string username) { List models = new BLL.InfectionOpenUserInfoBll().GetAllHangIntheAirQuestion(); for (int i = 0; i < models.Count; i++) { if (models[i].investigationState == "0") { models[i].investigationState = "未完成"; } else { models[i].investigationState = "已完成"; } } return Json(models); } /// /// 产生随机数 /// /// //public string RandomNumber() //{ // string dateTime = DateTime.Now.ToString("yyyyMMddHHmmss"); // Random random = new Random(); // string returnValue = dateTime + random.Next(99999, 1000000).ToString(); // return returnValue; //} /// /// 产生推荐码 /// /// /// [AllowAnonymous] public string RecommendNumber() { string returnValue = random.Next(0, 99999).ToString("D5"); return returnValue; } /// /// 获取手机验证码 /// /// 手机号 /// 验证码ID [AllowAnonymous] public JsonResult getsjyzm(string Mobile) { if (System.Text.RegularExpressions.Regex.IsMatch(Mobile, "^1[3|4|5|7|8]\\d{9}$")) { var dxyz = new BLL.DuanXinYanZhengBll(); string cookieid = Guid.NewGuid().ToString();// Request.Cookies["clientid"].Value; var yzm = dxyz.getYanZheng(Session.SessionID, cookieid, Request.UserHostAddress, Mobile); if (yzm.id == 0) { return Json(new { State = 0, Message = yzm.bz }); } else { var commonbll = new BLL.Common(); string yddx = commonbll.getParm_Value("qyyddx", "false", "是否启用移动短信"); if (yddx == "false") { string AccessKeyID = commonbll.getParm_Value("AccessKeyID", "LTAIWq3410bmP7hi", "阿里AccessKeyID"); string AccessKeySecret = commonbll.getParm_Value("AccessKeySecret", "F953Ru3uZN2ZbS5741zvO9OvHrthNV", "阿里AccessKeySecret"); string qm = commonbll.getParm_Value("aldxqm", "三才网络", "短信签名"); string dxmb = commonbll.getParm_Value("aldxmb_af", "SMS_142685019", "疫苗绑定短信模版"); //string smsurl = System.Configuration.ConfigurationManager.AppSettings["smsurl"]; //string yznr = "你好,欢迎你注册天瑞体检中心会员,你的验证码是:" + yzm.smscode + "。有效期10分钟。回TD退订【天瑞体检】"; //var zysms = new zyer.smsservice.SmsServiceSoapClient("SmsServiceSoap"); //var smsjg = zysms.SendEx(username, userpassword, "808", sjh, "", yznr); //var fz = Session["FenZhan"] as Model.FenZhan; //Common.SendMsg.Send(sjh, yznr, fz.id); String product = "Dysmsapi";//短信API产品名称 String domain = "dysmsapi.aliyuncs.com";//短信API产品域名 String accessKeyId = AccessKeyID;//你的accessKeyId String accessKeySecret = AccessKeySecret;//你的accessKeySecret IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", accessKeyId, accessKeySecret); //IAcsClient client = new DefaultAcsClient(profile); // SingleSendSmsRequest request = new SingleSendSmsRequest(); DefaultProfile.AddEndpoint("cn-hangzhou", "cn-hangzhou", product, domain); IAcsClient acsClient = new DefaultAcsClient(profile); SendSmsRequest request = new SendSmsRequest(); try { //必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为20个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式 request.PhoneNumbers = Mobile; //必填:短信签名-可在短信控制台中找到 request.SignName = qm; //必填:短信模板-可在短信控制台中找到 request.TemplateCode = dxmb; //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为 request.TemplateParam = Newtonsoft.Json.JsonConvert.SerializeObject(new { code = yzm.smscode }); //可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者 //request.OutId = "21212121211"; //请求失败这里会抛ClientException异常 SendSmsResponse sendSmsResponse = acsClient.GetAcsResponse(request); //System.Console.WriteLine(sendSmsResponse.Message); log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(sendSmsResponse.Message); } catch (ServerException e) { log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(e.Message + e.RequestId); //System.Console.WriteLine("Hello World!"); //return Json(new { State = 0, Message = e.Message}); } catch (ClientException e) { log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(e.Message + e.RequestId); //return Json(new { State = 0, Message = e.Message}); } return Json(new { State = 1, Message = yzm.id.ToString() }); } else { //http://112.35.1.155:1992/sms/norsubmit string ydhttp = commonbll.getParm_Value("ydhttp", "http://112.35.1.155:1992/sms/tmpsubmit", "移动短信地址"); var req = new Models.duanxin.msend(); req.ecName = commonbll.getParm_Value("yddxqymc", "德州市德城区疾病预防控制中心", "企业名称"); req.apId = commonbll.getParm_Value("yddxapId", "jkoa", "接口账号用户名"); req.mobiles = yzm.ShouJiHao; req.sign = commonbll.getParm_Value("yddxsign", "d37CYmrbG", "签名编码"); //req.content = "您的验证码" + yzm.smscode + ",该验证码5分钟内有效,请勿泄漏于他人!"; req.templateId = "f9037ad4c79b4212b9fdcd69f73d05c2"; req.addSerial = ""; string[] parms = new string[1]; parms[0] = yzm.smscode; req.parms = Newtonsoft.Json.JsonConvert.SerializeObject(parms); var md5 = MD5.Create(); //secretKey var bs = md5.ComputeHash(Encoding.UTF8.GetBytes(req.ecName + req.apId + commonbll.getParm_Value("yddxsecretKey", "a7551898", "短信接口密码") + req.templateId + req.mobiles + req.parms + req.sign)); var sb = new StringBuilder(); foreach (byte b in bs) { sb.Append(b.ToString("x2")); } req.mac = sb.ToString().ToLower(); WebClient wc = new WebClient(); string upstr = Newtonsoft.Json.JsonConvert.SerializeObject(req); upstr = upstr.Replace("parms", "params"); //new {params } //upstr.Insert(upstr.Length-1,",") byte[] resp = wc.UploadData(ydhttp, System.Text.Encoding.UTF8.GetBytes(Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(upstr)))); var nres = Newtonsoft.Json.JsonConvert.DeserializeObject(System.Text.Encoding.UTF8.GetString(resp)); log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(System.Text.Encoding.UTF8.GetString(resp)); return Json(new { State = 1, Message = yzm.id.ToString() }); } } } else { return Json(new { State = 0, Message = "请输入正确的手机号码!" }); } } #endregion #region 微信--体检信息操作 /// /// 获取全部体检预约信息 /// /// [AllowAnonymous] public JsonResult GetAllData_Test() { var bll = new BLL.InfectionTestBll(); List iouiList = bll.GetAllDataList(); return Json(iouiList); } /// /// 根据身份证号码获取数据 /// /// /// [AllowAnonymous] public JsonResult GetDataByIdent_Test(string ident) { var bll = new BLL.InfectionTestBll(); List iouiList = bll.GetDataByIdent(ident); return Json(iouiList); } /// /// 保存体检预约信息 /// /// /// [AllowAnonymous] public string SaveData_Test(InfectionTestModel model) { var yzmbll = new BLL.DuanXinYanZhengBll(); var bkyyrqbll = new BkyyrqBll(); if (string.IsNullOrEmpty(model.yzmid)) { return "手机验证码不正确!"; } var yzm = yzmbll.getYZMById(model.yzmid); if (yzm == null) { return "手机验证码不正确!"; } if (yzm.ShouJiHao != model.phone) { return "手机号码和获取验证码的手机号码不一致!"; } if ((DateTime.Now - yzm.sendtime).TotalMinutes > yzm.YanZhengYouXiaoQi) { return "验证码已经超过有效期!"; } if (yzm.state != 0) { return "验证码已经使用不能重复验证!"; } if (yzm.smscode != model.yzm) { return "手机验证码不正确!"; } //DateTime date = DateTime.Parse(model.order_date); //string week = date.DayOfWeek.ToString(); //switch (week) { // case "Saturday": // return "非工作日无法预约体检!"; // case "Sunday": // return "非工作日无法预约体检!"; //} if (model.state != 0) { model.state = 2; } int dayCheck = bkyyrqbll.checkDate(model.order_date); if (dayCheck == 1) { return "非工作日无法预约体检!"; } int user_id; try { user_id = int.Parse(Session["InfectionUserID"].ToString()); } catch { return "找不到个人信息!"; } InfectionOpenUserModel openUser = new InfectionOpenUserBll().GetDataByID(user_id.ToString()); InfectionOpenUserInfoModel openInfo = new InfectionOpenUserInfoBll().findByUserId(user_id); bool checkState = new InfectionTestBll().checkUserState(openInfo.id); if (openUser.state < 3) { return "请先完成调查问卷!"; } if (checkState) { return "已完成体检预约!"; } model.create_time = DateTime.Now.ToString(); string returnvalue = new BLL.InfectionTestBll().SaveData(model, user_id); if (returnvalue.Equals("预约成功!")) { try { InfectionOpenUserModel openuser = new InfectionOpenUserBll().GetDataByID(user_id.ToString()); InfectionOpenUserInfoModel openuserinfo = new InfectionOpenUserInfoBll().findByUserId(user_id); string sex = ""; if (openuser.sex == 1) { sex = "男"; } else if (openuser.sex == 2) { sex = "女"; } var data = new { touser = openuser.openid, template_id = "ZnclBAlcBizkU-7NTIvyIqDeJy1Ym8AsavTUJNXoKz0", url = "http://oa.dcqcdc.com/dccdc/Infection/Package", data = new { first = new { value = "你的体检预约已成功", color = "#173177" }, keyword1 = new { value = openuserinfo.name, color = "#173177" }, keyword2 = new { value = sex, color = "#173177" }, keyword3 = new { value = model.phone, color = "#173177" }, keyword4 = new { value = "健康大礼包", color = "#173177" }, keyword5 = new { value = model.order_date, color = "#173177" }, remark = new { value = "恭喜您,您的体检预约已成功。请您于" + model.order_date + "上午到德城区疾控中心体检,请务必空腹体检。如您有疑问或需要修改预约日程,请在本公众号留言或拨打电话2267105、2267111联系我们。", color = "#173177" }, } }; WebClient wc = new WebClient(); wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + Common.Global.getAccessTokenInfection.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data))); //InfectionOpenUserModel openUser = new InfectionOpenUserBll().GetDataByID(user_id.ToString()); //var text = new { content = "您的体检已预约成功!" }; //var data = new { openid = openUser.openid, msgtype = "text",text=text }; //WebClient wc = new WebClient(); //wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); //log4net.LogManager.GetLogger(this.GetType()).Info(Newtonsoft.Json.JsonConvert.SerializeObject(data)); //var result = wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + Common.Global.getAccessTokenInfection.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data))); //string jg = System.Text.Encoding.UTF8.GetString(result); //var rjg = Newtonsoft.Json.JsonConvert.DeserializeObject(jg); //if (rjg.errmsg == "ok") //{ // log4net.LogManager.GetLogger(this.GetType()).Info("预约成功!"); //} //else //{ // log4net.LogManager.GetLogger(this.GetType()).Info("预约失败!"); //} } catch (Exception ex) { return ex.Message; } } return returnvalue; } [AllowAnonymous] public JsonResult checkTestState() { int user_id; try { user_id = int.Parse(Session["InfectionUserID"].ToString()); } catch { return Json(new { State = 0, Message = "找不到个人信息!" }); } InfectionOpenUserModel openUser = new InfectionOpenUserBll().GetDataByID(user_id.ToString()); InfectionOpenUserInfoModel openInfo = new InfectionOpenUserInfoBll().findByUserId(user_id); if (openInfo == null) { return Json(new { State = 0, Message = "找不到个人信息!" }); } bool checkState = new InfectionTestBll().checkUserState(openInfo.id); if (openUser.state < 3) { return Json(new { State = 0, Message = "请先完成调查问卷!" }); } if (checkState) { return Json(new { State = 0, Message = "已完成体检预约!" }); } return Json(new { State = 1, Message = "" }); } [AllowAnonymous] public JsonResult GetDataByInfoID_Test() { int user_id; try { user_id = int.Parse(Session["InfectionUserID"].ToString()); } catch { return Json("找不到个人信息!"); } return Json(new BLL.InfectionTestBll().GetDataByUserID(user_id)); } /// /// 根据姓名,电话,身份证获取数据 /// /// /// /// /// [AllowAnonymous] public JsonResult GetDataByNamePhoneIdent_Test(string name, string phone) { int info_id; try { info_id = int.Parse(Session["InfectionUserID"].ToString()); } catch { return Json("找不到个人信息!"); } return Json(new BLL.InfectionTestBll().GetDataByNamePhoneIdent(name, phone, info_id)); } /// /// 根据ID获取预约信息 /// /// /// [AllowAnonymous] public JsonResult GetDataByID_Test(int id) { return Json(new BLL.InfectionTestBll().GetDataByID(id)); } /// /// 根据ID修改信息 /// /// /// [AllowAnonymous] public string ModifyDataByID_Test(InfectionTestModel model) { var bkyyrqbll = new BkyyrqBll(); string returnvalue = ""; if (model.state == 1) { int dayCheck = bkyyrqbll.checkDate(model.order_date); if (dayCheck == 1) { return "非工作日无法预约体检!"; } InfectionTestModel test = new BLL.InfectionTestBll().getOne(model.id.ToString()); if (test != null) { DateTime d1 = Convert.ToDateTime(test.order_date); DateTime d2 = Convert.ToDateTime(model.order_date); TimeSpan d3 = d2.Subtract(d1); if (d3.Days > 15) { return "修改预约日期不可超过15天!"; } } returnvalue = new BLL.InfectionTestBll().ModifyDataByID(model); int user_id; try { user_id = int.Parse(Session["InfectionUserID"].ToString()); } catch { return "找不到个人信息!"; } if (returnvalue.Equals("修改成功!")) { try { InfectionOpenUserModel openuser = new InfectionOpenUserBll().GetDataByID(user_id.ToString()); InfectionOpenUserInfoModel openuserinfo = new InfectionOpenUserInfoBll().findByUserId(user_id); string sex = ""; if (openuser.sex == 1) { sex = "男"; } else if (openuser.sex == 2) { sex = "女"; } var data = new { touser = openuser.openid, template_id = "ZnclBAlcBizkU-7NTIvyIqDeJy1Ym8AsavTUJNXoKz0", url = "http://oa.dcqcdc.com/dccdc/Infection/Package", data = new { first = new { value = "你的体检预约已修改", color = "#173177" }, keyword1 = new { value = openuserinfo.name, color = "#173177" }, keyword2 = new { value = sex, color = "#173177" }, keyword3 = new { value = model.phone, color = "#173177" }, keyword4 = new { value = "健康大礼包", color = "#173177" }, keyword5 = new { value = model.order_date, color = "#173177" }, remark = new { value = "恭喜您,您的体检预约已修改成功。请您于" + model.order_date + "上午到德城区疾控中心体检,请务必空腹体检。如您有疑问或需要修改预约日程,请在本公众号留言或拨打电话2267105、2267111联系我们。", color = "#173177" }, } }; WebClient wc = new WebClient(); wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + Common.Global.getAccessTokenInfection.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data))); } catch (Exception ex) { return ex.Message; } } } else if (model.state == 2) { returnvalue = new BLL.InfectionTestBll().AbolishOrder(model); } return returnvalue; } ///// ///// 根据姓名,电话,身份证获取体检信息 ///// ///// ///// //[AllowAnonymous] //public JsonResult GetDataByNamePhoneIdent_Test(string name, string phone, string ident) //{ // return Json(new BLL.InfectionTestBll().GetDataByNamePhoneIdent(name, phone, ident)); //} /// /// 根据姓名,电话,身份证获取身份信息 /// /// /// /// /// [AllowAnonymous] public JsonResult GetDataByNamePhoneIdent_register(string name, string phone, string ident, string yzmid, string yzm) { var yzmbll = new BLL.DuanXinYanZhengBll(); if (string.IsNullOrEmpty(yzmid)) { return Json(new { State = 0, Message = "手机验证码不正确!" }); } var yzmModel = yzmbll.getYZMById(yzmid); if (yzmModel == null) { return Json(new { State = 0, Message = "手机验证码不正确!" }); } if (yzmModel.ShouJiHao != phone) { return Json(new { State = 0, Message = "手机号码和获取验证码的手机号码不一致!" }); } if ((DateTime.Now - yzmModel.sendtime).TotalMinutes > yzmModel.YanZhengYouXiaoQi) { return Json(new { State = 0, Message = "验证码已经超过有效期!" }); } if (yzmModel.state != 0) { return Json(new { State = 0, Message = "验证码已经使用不能重复验证!" }); } if (yzmModel.smscode != yzm) { return Json(new { State = 0, Message = "手机验证码不正确!" }); } var list = new BLL.ProfessionalExamRegisterBll().GetDataByNamePhoneIdent(name, phone, ident); if (list.Count > 0) { return Json(new { State = 1, Message = list }); } else { return Json(new { State = 0, Message = "无数据" }); } } /// /// 根据姓名,电话,身份证获取身份信息 /// /// /// /// /// [AllowAnonymous] public JsonResult GetDataByNamePhoneIdent_list(string name, string ident) { var list = new BLL.ProfessionalExamRegisterBll().GetDataByNamePhoneIdent(name, "", ident); return Json(new { list }); } /// /// 根据id获取体检结果 /// /// /// [AllowAnonymous] public JsonResult GetDataByPersonId_ProjectResult(string id) { return Json(new professionalExam_project_resultBll().getPersonResult(id, "")); } #endregion #region 微信--红包信息操作 /// /// 微信红包 /// /// public ActionResult RedList() { return View(); } /// /// 获取微信红包 /// /// public ActionResult GetAllRed() { InfectionRedBll bill = new InfectionRedBll(); List redList = bill.GetRedList(); return Json(redList); } /// /// 添加签到红包 /// /// /// [AllowAnonymous] public ActionResult AddDayRed(InfectionRedModel model) { InfectionCheckBll checkBll = new InfectionCheckBll(); infectionRedMoneyBll mBill = new infectionRedMoneyBll(); InfectionRedBll bill = new InfectionRedBll(); infectionRedMoneyModel mModel = mBill.getInitData(); InfectionOpenUserModel openuser = new InfectionOpenUserBll().GetDataByID(Session["InfectionUserID"].ToString()); InfectionOpenUserInfoModel info = new InfectionOpenUserInfoBll().findByUserId(openuser.id); int redcode = 0; int signInDays = new InfectionCheckBll().getCheckSum(openuser.id.ToString()); int checkToday = new InfectionCheckBll().checkToday(openuser.id.ToString()); int redToday = new InfectionRedBll().redToday(openuser.openid); double redAllToday = new InfectionRedBll().redAllToday(); double daydouble = (random.Next(30, 51)) * 0.01; decimal daymoney = Decimal.Parse(daydouble.ToString()); string receive = ""; string top = ""; return Json(new { receive, again=false, top="红包发送活动已结束!感谢您的参与!" }); //if (signInDays >= mModel.days) log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Info("checkToday:" + checkToday); if (checkToday > 0) { log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Info("redToday:" + redToday); if (redToday == 0) { if (redAllToday + daydouble <= 100) { int iMin = 1000; int iMax = 9999; Random rd = new Random();//构造随机数 string strMch_billno = Common.Global.InfectionMchId + DateTime.Now.ToString("yyyyMMddHHmmss") + rd.Next(iMin, iMax).ToString(); model.openid = openuser.openid; model.phone = info.phone; model.sum = daymoney; model.state = 0; model.type = 1; model.create_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); model.mch_billno = strMch_billno; redcode = bill.InsertRed(model); log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Info("daymoney:" + daymoney); InfectionWXController infectionWX = new InfectionWXController(); receive = infectionWX.sendRedPack(openuser.openid, Convert.ToInt32(daymoney * 100), strMch_billno); log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Info("receive:" + receive); } else { top = "今日红包已发放完"; } } } bool again = true; if (!string.IsNullOrEmpty(receive)) { log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Info("receive=====================================" + receive); bill.UpdateState(redcode.ToString(), receive); //new BLL.InfectionCheckBll().updateCheckState(openuser.id.ToString(), mModel.days); new BLL.InfectionCheckBll().updateTodayCheckState(openuser.id.ToString()); again = false; } //int againDays = new InfectionCheckBll().getCheckSum(openuser.id.ToString()); //if (againDays >= mModel.days) //{ // again = true; //} return Json(new { receive, again, top }); } /// /// 添加预约红包 /// /// /// public ActionResult AddTestRed(InfectionRedModel model) { infectionRedMoneyBll mBill = new infectionRedMoneyBll(); InfectionRedBll bill = new InfectionRedBll(); infectionRedMoneyModel mModel = mBill.getInitData(); InfectionOpenUserModel openuser = new InfectionOpenUserBll().GetDataByID(Session["InfectionUserID"].ToString()); model.openid = openuser.openid; model.sum = mModel.testmoney; model.state = 0; model.create_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); int result = bill.InsertRed(model); return Json(result); } /// /// 更改签到状态 /// /// /// //public ActionResult EditRedState(string id) //{ // InfectionRedBll bill = new InfectionRedBll(); // return Json(bill.UpdateState(id)); //} #endregion #region 微信--签到信息操作 #endregion #region 微信--问卷调查操作 /// /// 保存问卷调查答案 /// /// /// [AllowAnonymous] public string SaveData_QuestionAnswer(string json, int id, string username) { ERPUser m = new ERPUserBll().login(username, ""); //log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("id=====================" + id); string returnValue = null; string address = string.Empty; if (Request.Files.Count != 0) { string path = string.Empty; try { path = Server.MapPath("~/music/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string specificDate = DateTime.Now.ToString("yyyyMMdd").ToString(); path += specificDate + "/"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } address = DateTime.Now.ToString("HHmmss") + "-" + Guid.NewGuid().ToString() + ".mp3"; path += address; Request.Files[0].SaveAs(path); address = specificDate + "/" + address; InfectionQuestionRecordModel questionRecordModel = new InfectionQuestionRecordModel(); questionRecordModel.record = address; questionRecordModel.sheet_id = getSheetId(); questionRecordModel.info_id = id; questionRecordModel.create_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); questionRecordModel.create_by = m.ID.ToString(); new BLL.InfectionQuestionRecordBll().saveQuestionData(questionRecordModel); } catch { returnValue = "录音保存失败!"; } } //int user_id; //try //{ // user_id = int.Parse(Session["InfectionAppUserId"].ToString()); //} //catch //{ // return "找不到个人信息!"; //} if (!string.IsNullOrEmpty(json)) { if (new BLL.InfectionQuestionAnswerBll().deleteData(id)) { json = json.Replace("{", ""); json = json.Replace("}", ""); json = json.Replace("\"", ""); String[] stringArr = json.Split(','); for (int i = 0; i < stringArr.Length; i++) { InfectionQuestionAnswerModel model; model = new InfectionQuestionAnswerModel(); model.question_id = i + 1; model.question_sign = stringArr[i].ToString().Substring(0, stringArr[i].ToString().IndexOf(":")); if (stringArr[i].ToString().Substring(0, stringArr[i].ToString().IndexOf(":")).Equals("A03")) { model.answer = DateTime.Now.ToString("yyyy-MM-dd"); } else { model.answer = stringArr[i].ToString().Substring(stringArr[i].ToString().IndexOf(":") + 1); } //model.user_id = int.Parse(Session["InfectionUserID"].ToString()); model.info_id = id; model.create_by = m.ID.ToString(); model.create_time = DateTime.Now.ToString(); string result = new BLL.InfectionQuestionAnswerBll().SaveData(model); if (result.Equals("False")) { returnValue = "操作失败!"; break; } else { returnValue = "保存成功!"; } } } infectionRedMoneyBll mBill = new infectionRedMoneyBll(); InfectionRedBll bill = new InfectionRedBll(); infectionRedMoneyModel mModel = mBill.getInitData(); InfectionOpenUserInfoBll infobll = new InfectionOpenUserInfoBll(); InfectionOpenUserInfoModel infomodel = infobll.findById(id); log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("infoid=====================" + infomodel.id); log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("questionnairemoney=====================" + mModel.questionnairemoney); if (mModel.questionnairemoney > 0) { if (infomodel != null && infomodel.user_id != 0) { int iMin = 1000; int iMax = 9999; Random rd = new Random();//构造随机数 string strMch_billno = Common.Global.InfectionMchId + DateTime.Now.ToString("yyyyMMddHHmmss") + rd.Next(iMin, iMax).ToString(); InfectionOpenUserModel openUser = new InfectionOpenUserBll().GetDataByID(infomodel.user_id.ToString()); InfectionRedModel redmodel = new InfectionRedModel(); redmodel.openid = openUser.openid; redmodel.phone = infomodel.phone; redmodel.sum = mModel.questionnairemoney; redmodel.state = 0; redmodel.create_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); redmodel.type = 2; redmodel.mch_billno = strMch_billno; int redresult = bill.InsertRed(redmodel); InfectionWXController wxcontroller = new InfectionWXController(); string redcode = wxcontroller.sendRedPack(openUser.openid, (int)(mModel.questionnairemoney * 100), strMch_billno); //log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("redcode=====================" + redcode); if (!string.IsNullOrEmpty(redcode)) { bill.UpdateState(redresult.ToString(), redcode); } } } InfectionOpenUserInfoModel userinfo = infobll.findById(id); InfectionOpenUserModel openuser = new InfectionOpenUserBll().GetDataByID(userinfo.user_id.ToString()); var data = new { touser = openuser.openid, template_id = "5ZVqfZRB-_st7nKTFkNusQWvyLDiVSUpKF0v3aoV-js", url = "http://oa.dcqcdc.com/dccdc/Infection/subscribeInfo", data = new { first = new { value = "您好,您已完成调查问卷", color = "#173177" }, keyword1 = new { value = "问卷调查", color = "#173177" }, keyword2 = new { value = "德城健康e路", color = "#173177" }, //keyword3 = new { value = model.ADate.ToString("yyyy-MM-dd"), color = "#173177" }, remark = new { value = "您好,在您的配合下,我们顺利完成了健康问卷调查,作为奖励,我们将为您提供免费的健康体检大礼包,请点击预约体检。", color = "#173177" }, } }; WebClient wc = new WebClient(); wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + Common.Global.getAccessTokenInfection.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data))); var data2 = new { touser = openuser.openid, template_id = "5ZVqfZRB-_st7nKTFkNusQWvyLDiVSUpKF0v3aoV-js", data = new { first = new { value = "您好,您已完成调查问卷", color = "#173177" }, keyword1 = new { value = "问卷调查", color = "#173177" }, keyword2 = new { value = "德城健康e路", color = "#173177" }, //keyword3 = new { value = model.ADate.ToString("yyyy-MM-dd"), color = "#173177" }, remark = new { value = "请您继续关注本公众号,目前我们已向您推出“答题领红包”项目,每天只需答题一次,就有机会获得红包奖励。", color = "#173177" }, } }; WebClient wc2 = new WebClient(); wc2.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + Common.Global.getAccessTokenInfection.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data2))); InfectionOpenUserInfoModel info = new InfectionOpenUserInfoBll().findById(id); new InfectionOpenUserBll().updateUserStateById(info.user_id); } return returnValue; } /// /// 根据姓名、单位、电话获取数据 /// /// /// /// /// [AllowAnonymous] public JsonResult GetDataListNameUnitPhone_OpenUserInfo(string name, string unit, string phone) { return Json(new BLL.InfectionOpenUserInfoBll().GetDataListNameUnitPhone(name, unit, phone)); } #endregion #region 微信--人群维护操作 /// /// 获取已启用的所属人群 /// /// [AllowAnonymous] public JsonResult GetAllIDNameIsQuestion() { return Json(new BLL.InfectionOpenCrowdBll().GetAllIDNameIsQuestion()); } #endregion #region 微信--知识库 [AllowAnonymous] public JsonResult GetAllData_Repository() { List models = new BLL.InfectionRepositoryBll().GetAllData(); return Json(models); } [AllowAnonymous] public string GetDataByID_Repository(string id) { return Newtonsoft.Json.JsonConvert.SerializeObject(new BLL.InfectionRepositoryBll().GetDataByID(int.Parse(id))); } #endregion #region 问卷调查操作 public ActionResult QuestionnaireList() { int monthOne = new InfectionOpenUserBll().getMonthOne(); int monthTwo = new InfectionOpenUserBll().getMonthTwo(); int allOne = new InfectionOpenUserBll().getAllOne(); int allTwo = new InfectionOpenUserBll().getAllTwo(); ViewBag.monthOne = monthOne; ViewBag.monthTwo = monthTwo; ViewBag.allOne = allOne; ViewBag.allTwo = allTwo; return View(); } /// /// 根据姓名、身份证号分页查询 /// /// /// /// /// /// public JsonResult getCheckQuestionnaireList(int page, int pagesize, string name, string ident) { var bll = new BLL.InfectionOpenUserInfoBll(); List ouiList = bll.getCheckQuestionnaireList(page, pagesize, name, ident); int count = bll.getDataCount(name, ident); return Json(new { Total = count, Rows = ouiList }); } public ActionResult QuestionnaireModify(string info_id) { InfectionQuestionAnswerModel model = new InfectionQuestionAnswerModel(); string adminId = new BLL.Common().getParm_Value("InfectionAdmin", "32", "艾防后台管理员账号"); ViewBag.isAdmin = 0; if (Session["loginUser"] != null) { Models.ERPUser erpuser = Session["loginUser"] as Models.ERPUser; if (erpuser.ID == int.Parse(adminId)) { ViewBag.isAdmin = 1; } } //ERPUser erpuser = Session["loginUser"] as ERPUser; model.info_id = Convert.ToInt32(info_id); return View(model); } /// /// 根据user_id获取数据 /// /// /// public JsonResult QuestionnaireModifydetails(string info_id) { List modelList = new InfectionQuestionAnswerBll().getDataListByUserID(info_id); return Json(new { Rows = modelList }); } /// /// 根据info_id获取录音数据 /// /// /// public JsonResult QuestionnaireModifyDetailsRecord(string info_id) { List modelList = new InfectionQuestionRecordBll().getDataListByUserID(info_id); List pathList = new List(); for (int i = 0; i < modelList.Count; i++) { string path = "/dccdc/music/"; path += modelList[i].record; pathList.Add(path); } return Json(new { Rows = modelList, Path = pathList }); } /// /// 修改问卷答案 /// /// /// public JsonResult saveQuestionnaire(InfectionQuestionRecordModel model) { return Json(new BLL.InfectionQuestionRecordBll().saveData(model)); } /// /// 保存问卷记、答案和上传文件 /// /// /// public JsonResult questionnaireAddData(string json, string id) { object returnValue = null; string address = string.Empty; if (Request.Files.Count != 0) { string path = string.Empty; try { path = Server.MapPath("~/music/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string specificDate = DateTime.Now.ToString("yyyyMMdd").ToString(); path += specificDate + "/"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } address = DateTime.Now.ToString("HHmmss") + "-" + Guid.NewGuid().ToString() + ".mp3"; path += address; Request.Files[0].SaveAs(path); address = specificDate + "/" + address; InfectionQuestionRecordModel questionRecordModel = new InfectionQuestionRecordModel(); questionRecordModel.record = address; questionRecordModel.sheet_id = getSheetId(); questionRecordModel.info_id = int.Parse(id); ERPUser erpuser = Session["loginUser"] as ERPUser; questionRecordModel.create_by = erpuser.ID.ToString(); questionRecordModel.create_time = DateTime.Now.ToString(); } catch { returnValue = new { State = 0, Message = "录音保存失败!" }; } } if (!string.IsNullOrEmpty(json)) { if (new BLL.InfectionQuestionAnswerBll().deleteData(int.Parse(id))) { json = json.Replace("{", ""); json = json.Replace("}", ""); json = json.Replace("\"", ""); String[] stringArr = json.Split(','); InfectionQuestionAnswerModel model; for (int i = 0; i < stringArr.Length; i++) { model = new InfectionQuestionAnswerModel(); model.question_id = i + 1; model.question_sign = stringArr[i].ToString().Substring(0, stringArr[i].ToString().IndexOf(":")); model.answer = stringArr[i].ToString().Substring(stringArr[i].ToString().IndexOf(":") + 1); model.info_id = int.Parse(id); model.create_time = DateTime.Now.ToString(); string result = new BLL.InfectionQuestionAnswerBll().SaveData(model); if (result.Equals("False")) { returnValue = new { State = 0, Message = "操作失败!" }; break; } else { returnValue = new { State = 1, Message = "保存成功!" }; } } } } return Json(returnValue); } //修改问卷 public JsonResult questionnaireUpdateData(string json, string id) { object returnValue = null; string address = string.Empty; string info_id = id.Replace("{", ""); info_id = info_id.Replace("}", ""); string[] info = info_id.Split(':'); if (info.Length > 1) { info_id = info[1].Replace("\"", "").Trim(); } InfectionOpenUserInfoModel userInfo = new InfectionOpenUserInfoBll().getOne2(info_id); if (Request.Files[0].ContentLength > 0) { string path = string.Empty; try { path = Server.MapPath("~/music/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string specificDate = DateTime.Now.ToString("yyyyMMdd").ToString(); path += specificDate + "/"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } address = DateTime.Now.ToString("HHmmss") + "-" + Guid.NewGuid().ToString() + ".mp3"; path += address; Request.Files[0].SaveAs(path); address = specificDate + "/" + address; InfectionQuestionRecordModel questionRecordModel = new InfectionQuestionRecordModel(); questionRecordModel.record = address; questionRecordModel.sheet_id = getSheetId(); questionRecordModel.info_id = int.Parse(info_id); ERPUser erpuser = Session["loginUser"] as ERPUser; questionRecordModel.create_by = erpuser.ID.ToString(); questionRecordModel.create_time = DateTime.Now.ToString(); InfectionQuestionRecordBll rbll = new InfectionQuestionRecordBll(); rbll.saveQuestionData(questionRecordModel); } catch { returnValue = new { State = 0, Message = "录音保存失败!" }; } } json = json.Replace("{", ""); json = json.Replace("}", ""); json = json.Replace("\"", ""); String[] stringArr = json.Split(','); InfectionQuestionAnswerModel model; new BLL.InfectionQuestionAnswerBll().delete(info_id); for (int i = 0; i < stringArr.Length; i++) { model = new InfectionQuestionAnswerModel(); model.question_id = i + 1; model.question_sign = stringArr[i].ToString().Substring(0, stringArr[i].ToString().IndexOf(":")); model.answer = stringArr[i].ToString().Substring(stringArr[i].ToString().IndexOf(":") + 1); model.info_id = int.Parse(info_id); model.create_time = DateTime.Now.ToString("yyyy/MM/dd"); string result = new BLL.InfectionQuestionAnswerBll().updateData(model); if (result.Equals("False")) { returnValue = new { State = 0, Message = "操作失败!" }; break; } else { returnValue = new { State = 1, Message = "保存成功!" }; } } return Json(returnValue); } [AllowAnonymous] public string getSheetId() { string sheetId = new InfectionQuestionRecordBll().getSheetId(); int sheetid = 00001; if (!string.IsNullOrEmpty(sheetId)) { if (!sheetId.Equals("序列不包含任何元素")) { sheetid = int.Parse(sheetId.Substring(6, 5)); sheetid = sheetid + 1; } } return "371402" + sheetid.ToString("D5"); } //删除问卷录音 public JsonResult deleteFile(string id) { string path = Server.MapPath("~/music/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } InfectionQuestionRecordBll bll = new InfectionQuestionRecordBll(); InfectionQuestionRecordModel modelList = bll.getDataById(id); modelList.record = path + modelList.record; System.IO.File.Delete(modelList.record);//删除文件 string val = bll.delete(id); if (val.Equals("True")) { return Json(new { State = 1, Message = "操作成功!" }); } return Json(new { State = 0, Message = "操作失败!" }); } #endregion #region 个人信息查询画面的查询方法 public JsonResult getOpenUserInfoList(int page, int pagesize, string name, string unit, string phone, string pass_by) { var bll = new BLL.InfectionOpenUserInfoBll(); int count = bll.getCount(name, unit, phone, pass_by); List ctList = bll.getList(page, pagesize, name, unit, phone, pass_by); return Json(new { Total = count, Rows = ctList }); } #endregion #region 人群维护 public ActionResult CrowdMaintenance() { return View(); } /// /// 获取全部所属人群 /// /// public JsonResult getCheckCrowdMaintenance() { List models = new BLL.InfectionOpenCrowdBll().GetAllDataList(); for (int i = 0; i < models.Count; i++) { if (models[i].create_by == 1) { models[i].creater = "admin"; } } return Json(new { Rows = models }); } /// /// 保存所属人群 /// /// /// public JsonResult saveCheckCrowdMaintenance(InfectionOpenCrowdModel model) { model.create_by = 1; model.create_time = DateTime.Now.ToString(); return Json(new BLL.InfectionOpenCrowdBll().saveData(model)); } /// /// 根据id删除所属人群 /// /// /// public JsonResult deleteCheckCrowdMaintenance(string id) { return Json(new BLL.InfectionOpenCrowdBll().deleteData(id)); } #endregion #region 签到问题维护 public ActionResult CheckQuestion() { return View(); } /// /// 获取全部问题 /// /// public JsonResult getCheckQuestionList() { List models = new BLL.InfectionDaysignQuestionBll().GetAllDataList(); for (int i = 0; i < models.Count; i++) { if (models[i].create_by == 1) { models[i].creater = "admin"; } } return Json(new { Rows = models }); } /// /// 获取今日问题 /// /// [AllowAnonymous] public JsonResult getCheckQuestion() { InfectionDaysignQuestionModel model = new BLL.InfectionDaysignQuestionBll().GetOneRandomQuestion(); List optionsList = new BLL.InfectionDaysignQuestionOptionsBll().getRandomOption(model.id); model.optionlist = optionsList; JsonResult json = Json(new { Question = model }, JsonRequestBehavior.AllowGet); return json; } /// /// 保存问题 /// /// /// public JsonResult saveCheckQuestion(InfectionDaysignQuestionModel model) { model.create_by = 1; model.create_time = DateTime.Now.ToString(); return Json(new BLL.InfectionDaysignQuestionBll().saveData(model)); } /// /// 保存问题 /// /// /// public JsonResult getQuestionOptions(int id) { List optionsList = new BLL.InfectionDaysignQuestionOptionsBll().getOptionList(id); return Json(new { State = 1, Message = "保存成功!", options = optionsList }); } /// /// 根据id删除问题 /// /// /// public JsonResult deleteCheckQuestion(string id) { return Json(new BLL.InfectionDaysignQuestionBll().deleteData(id)); } #endregion #region 从业登记 /// /// /// /// /// 2:登记后修改 1:复检 0:正常 /// [HttpGet] public ActionResult EmploymentRegistration(string tm, string tjzt) { if (tm != null && (tjzt == "1" || tjzt == "2")) { ViewBag.disabled = "disabled"; ProfessionalExamRegisterBll bll = new ProfessionalExamRegisterBll(); var dtomodel = tjzt == "1" ? bll.GetfjModel(tm) : bll.getModel(tm); AutoMapper.Mapper.Initialize(x => x.CreateMap()); var vm = AutoMapper.Mapper.Map(dtomodel); ViewBag.src = "data:image/jpeg;base64," + vm.phone_path; ViewBag.tjzt = tjzt; ViewData["zgzt"] = new SelectList(new checktypemaintainBll().GetListBybelong("职业"), "id", "check_type"); var items = new List { new SelectListItem { Text = "卡车司机", Value = "4" } }; var selectList = new SelectList(items, "Value", "Text"); ViewData["tjfn"] = selectList;// new SelectList(new MedicalSchemeMaintainBll().GetAllList(), "id", "medical_scheme", vm.medical_scheme_maintain_id); ViewData["hylb"] = selectList;// new SelectList(new TradeTypeMaintainBll().GetAllTreeList(), "id", "trade_name", vm.trade_type_maintain_id); //ViewData["dq"] = new SelectList(new AreaInfoMaintainBll().GetAllList(), "area_name", "area_name", vm.area); ViewData["hj"] = new SelectList(new NativeInfoMaintainBll().GetAllList(), "id", "natives", vm.native_info_maintain_id); //ViewData["gz"] = new SelectList(new WorkTypeMaintainBll().GetAllTreeList(), "work_type_name", "work_type_name", vm.work_category); ViewData["rylx"] = new SelectList(new PersonTypeMaintainBll().GetAllList("", "是"), "id", "type_name", vm.person_type_maintain_id); vm.tjzt = tjzt; vm.tjxm = dtomodel.check_item_ids; vm.special_health_certificate1 = dtomodel.special_health_certificate == "快速办证"; return View(vm); } else { ViewBag.disabled = "Enabled"; ViewBag.tjzt = 0; ViewData["zgzt"] = new SelectList(new checktypemaintainBll().GetListBybelong("职业"), "id", "check_type"); //var items = new List { new SelectListItem { Text = "卡车司机", Value = "4" } }; //var selectList = new SelectList(items, "Value", "Text"); ViewData["tjfn"] = new SelectList(new MedicalSchemeMaintainBll().GetAllListByCrowd(), "id", "medical_scheme"); ViewData["hylb"] = new SelectList(new TradeTypeMaintainBll().GetAllTreeListByCrowd(), "id", "trade_name"); ViewData["dq"] = new SelectList(new AreaInfoMaintainBll().GetAllList(), "id", "area_name"); ViewData["hj"] = new SelectList(new NativeInfoMaintainBll().GetAllList(), "id", "natives"); ViewData["gz"] = new SelectList(new WorkTypeMaintainBll().GetAllTreeList(), "id", "work_type_name"); ViewData["rylx"] = new SelectList(new PersonTypeMaintainBll().GetAllList("", "是"), "id", "type_name"); return View(); } } public string GettrandeModel(string name) { TradeTypeMaintainBll bll = new TradeTypeMaintainBll(); TradeTypeMaintainModel model = bll.GetModelBytradename(name); return JsonConvert.SerializeObject(model); } public string MedicalModel(string name) { MedicalSchemeMaintainBll bll = new MedicalSchemeMaintainBll(); MedicalSchemeMaintainModel model = bll.GetmodelByName(name); return JsonConvert.SerializeObject(model); } public string CheckDay(string cardnumber, string tradeTypeMaintainId = "", string examType = "从业人员体检") { ProfessionalExamRegisterBll bll = new ProfessionalExamRegisterBll(); string f = bll.CheckDay(cardnumber, tradeTypeMaintainId, examType); return (f == "true") ? "true" : "false"; } /// /// 根据体检方案ID查询收费项目 /// /// /// public string GetsfxmBytjfnid(string tjfnid) { MedicalSchemeChargeMaintainBll bll = new MedicalSchemeChargeMaintainBll(); List al = bll.GetListBymedicalschememaintainid(tjfnid); string modelslistjson = JsonConvert.SerializeObject(al); ; return "{\"Rows\":" + modelslistjson + "}"; } /// /// 根据体检方案ID查询体检项目 /// /// /// public string GettjxmByfnid(string tjfnid) { medical_scheme_project_maintainBll bll = new medical_scheme_project_maintainBll(); List al = bll.GetListBymedicalschememaintainid(tjfnid); List f = new List(); foreach (var medicalSchemeProjectMaintainModel in al) { f ff = new f { exam_group = medicalSchemeProjectMaintainModel.team_name, project_id = medicalSchemeProjectMaintainModel.exam_project_maintain_project_id, project_name = medicalSchemeProjectMaintainModel.project_name }; f.Add(ff); } string modelslistjson = JsonConvert.SerializeObject(f); return "{\"Rows\":" + modelslistjson + "}"; } public class f { public string project_id { get; set; } public string project_name { get; set; } public string exam_group { get; set; } } public ActionResult EmploymentRegistration(RegisterCydjViewModel vm, string mid) { ViewData["zgzt"] = new SelectList(new checktypemaintainBll().GetListBybelong("职业"), "id", "check_type"); //var items = new List { new SelectListItem { Text = "卡车司机", Value = "4" } }; //var selectList = new SelectList(items, "Value", "Text"); ViewData["tjfn"] = new SelectList(new MedicalSchemeMaintainBll().GetAllListByCrowd(), "id", "medical_scheme"); ViewData["hylb"] = new SelectList(new TradeTypeMaintainBll().GetAllTreeListByCrowd(), "id", "trade_name"); ViewData["dq"] = new SelectList(new AreaInfoMaintainBll().GetAllList(), "id", "area_name"); ViewData["hj"] = new SelectList(new NativeInfoMaintainBll().GetAllList(), "id", "natives"); ViewData["gz"] = new SelectList(new WorkTypeMaintainBll().GetAllTreeList(), "id", "work_type_name"); ViewData["rylx"] = new SelectList(new PersonTypeMaintainBll().GetAllList("", "是"), "id", "type_name"); ModelState.Remove("id"); ModelState.Remove("native_info_maintain_id"); if (!ModelState.IsValid) { return View(vm); } vm.phone_path = vm.phone_path.Replace("data:image/jpeg;base64,", ""); var erpUser = Session["loginUser"] as Models.ERPUser; if (erpUser != null) { vm.register_person = erpUser.TrueName; } AutoMapper.Mapper.Initialize( x => x.CreateMap()); var dtocydj = AutoMapper.Mapper.Map(vm); ProfessionalExamRegisterBll bll = new ProfessionalExamRegisterBll(); List tjxmal = new List(); dtocydj.special_health_certificate = vm.special_health_certificate1 ? "快速办证" : ""; dtocydj.jgid = Common.Global.jgid; if (!string.IsNullOrEmpty(vm.tjxm)) { tjxmal = new ExamProjectMaintainBll().GetAllListByprojectids(vm.tjxm.TrimEnd(',')); // tjxmal = new MedicalSchemeChargeMaintainBll().GetAllListByprojectids(vm.tjxm.TrimEnd(','),vm.); } string f = ""; switch (vm.tjzt) { case "1": List fjsfxmal = new List(); ChargeProjectMaintainModel fjsfxmmodel = new ChargeProjectMaintainModel(); fjsfxmmodel.charge_project_name = "复查费"; fjsfxmmodel.fee = "50"; fjsfxmal.Add(fjsfxmmodel); f = bll.Fjdj(dtocydj, fjsfxmal); break; case "2": AutoMapper.Mapper.Initialize( x => x.CreateMap()); var dtocydj1 = AutoMapper.Mapper.Map(vm); dtocydj1.special_health_certificate = vm.special_health_certificate1 ? "快速办证" : ""; dtocydj1.jgid = Common.Global.jgid; bll.Update(dtocydj1); f = dtocydj1.physical_num; break; case "0": int imid = 0; int.TryParse(mid, out imid); List sfxmal = new MedicalSchemeChargeMaintainBll().GetAllListBysfxmId(vm.sfxm.TrimEnd(','), vm.medical_scheme_maintain_id); f = bll.Cydj(dtocydj, sfxmal, tjxmal, imid); new InfectionTestBll().UpdateTestState(imid); #region MyRegion //string ident = vm.card_number; //infectionRedMoneyBll mBill = new infectionRedMoneyBll(); //InfectionRedBll bill = new InfectionRedBll(); //infectionRedMoneyModel mModel = mBill.getInitData(); //InfectionOpenUserInfoBll infobll = new InfectionOpenUserInfoBll(); //InfectionOpenUserInfoModel infomodel = infobll.GetInfoByIdent(ident); //if (infomodel != null) //{ // InfectionOpenUserModel openuser = new InfectionOpenUserBll().GetDataByID(infomodel.user_id.ToString()); // InfectionRedModel redmodel = new InfectionRedModel(); // if (mModel.testmoney > 0) // { // redmodel.openid = openuser.openid; // redmodel.sum = mModel.testmoney; // redmodel.state = 0; // redmodel.create_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // redmodel.type = 3; // int redresult = bill.InsertRed(redmodel); // InfectionWXController wxcontroller = new InfectionWXController(); // string redcode = wxcontroller.sendRedPack(openuser.openid, (int)(mModel.questionnairemoney * 100)); // if (!string.IsNullOrEmpty(redcode)) // { // bill.UpdateState(redresult.ToString(),redcode); // } // } //} #endregion break; } //2:登记后修改 1:复检 0:正常 var txm = vm.txm ? "1" : "0"; var zyd = vm.zyd ? "1" : "0"; return Json(new { State = 1, Message = "操作成功!", dy = "0", txm = txm, zyd = zyd, tm = f }); } /// /// 根据体检项目ID查询体检项目列表 /// /// /// public string GettjxmByIDs(string ids) { ExamProjectMaintainBll bll = new ExamProjectMaintainBll(); string modelslistjson = JsonConvert.SerializeObject(bll.GetTjfnmxByIDs(ids)); return "{\"Rows\":" + modelslistjson + "}"; } /// /// 根据体检项目查询收费项目列表 /// /// public string Getsfxm(string ids) { ChargeProjectMaintainBll bll = new ChargeProjectMaintainBll(); string modelslistjson = JsonConvert.SerializeObject(bll.GetAllListBytjxm(ids)); return "{\"Rows\":" + modelslistjson + "}"; } [AllowAnonymous] public string GetRegisteModel(string tm) { ProfessionalExamRegisterBll bll = new ProfessionalExamRegisterBll(); ProfessionalExamRegisterModel model = bll.getModel(tm); List mls = new List { model }; return JsonConvert.SerializeObject(mls); } #endregion #region 登记人员信息列表 public ActionResult EmploymentList(string lx) { ViewBag.lx = lx; return View(); } public JsonResult GetRegisteList(int page, int pagesize, string name, string sitename, string startdate, string endtime, string lx) { var bll = new ProfessionalExamRegisterBll(); int count = bll.getCount(name, sitename, startdate, endtime, lx); List ctList = bll.getList(page, pagesize, name, sitename, startdate, endtime, lx); return Json(new { Total = count, Rows = ctList }); } #endregion #region 职业复检登记人员信息列表 public ActionResult ZyFjResult() { ViewData["ssqy"] = new SelectList(new AreaInfoMaintainBll().GetAllList(), "id", "area_name"); return View(); } public string GetZyFjList(string sitename, string tm, string name, string starttime, string endtime, string ssqy) { ProfessionalExamRegisterBll bll = new ProfessionalExamRegisterBll(); string modelslistjson = JsonConvert.SerializeObject(bll.GetZyfjList(sitename, tm, name, starttime, endtime, ssqy)); return "{\"Rows\":" + modelslistjson + "}"; } #endregion #region 复检登记人员信息列表 public ActionResult EmploymentReexamination() { ViewData["ssqy"] = new SelectList(new AreaInfoMaintainBll().GetAllList(), "id", "area_name"); return View(); } public string GetEmploymentReexaminationList(string sitename, string tm, string name, string starttime, string endtime, string ssqy) { ProfessionalExamRegisterBll bll = new ProfessionalExamRegisterBll(); string modelslistjson = JsonConvert.SerializeObject(bll.GetfjList(sitename, tm, name, starttime, endtime, ssqy)); return "{\"Rows\":" + modelslistjson + "}"; } #endregion #region 初始化 SelectList /// /// 初始化 SelectList(体检方案) /// /// /// 默认选中 /// public SelectList GetSelectListtjfn(IEnumerable list, string selected = "请选择") { var items = new List { new SelectListItem { Text = "----请选择----", Value = "-1" } }; if (list == null) { return new SelectList(items, "Value", "Text"); } items.AddRange(list.Select(item => new SelectListItem { Text = item.scheme_name, Value = item.id.ToString() })); var selectList = new SelectList(items, "Value", "Text", selected); return selectList; } #endregion #region 从业检查 public ActionResult EmploymentInspection() { List list = new InfectionOpenCrowdBll().GetOpenDataList(); List itemList = new List(); SelectListItem items = new SelectListItem() { Value = "-1", Text = "---请选择---" }; itemList.Add(items); foreach (InfectionOpenCrowdModel crowd in list) { SelectListItem item = new SelectListItem() { Value = crowd.id.ToString(), Text = crowd.name.ToString() }; itemList.Add(item); } SelectList select = new SelectList(itemList, "Value", "Text"); ViewBag.crowdList = select; return View(); } public string getDataInspection(string start, string end, string where, string sort, string crowd) { if (string.IsNullOrEmpty(start) || string.IsNullOrEmpty(end) || string.IsNullOrEmpty(sort)) return Newtonsoft.Json.JsonConvert.SerializeObject(null); var bll = new ProfessionalExamRegisterBll(); var result = bll.getDataEmploymentInspectionInfection(start, end, where, sort, crowd); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = result }); } public ActionResult exportDataInspection(string start, string end, string where, string sort, string crowd) { try { var bll = new ProfessionalExamRegisterBll(); var list = bll.getDataEmploymentInspectionInfection(start, end, where, sort, crowd); //创建Excel文件的对象 NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(); //添加一个sheet NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1"); sheet1.SetColumnWidth(0, 13 * 256); sheet1.SetColumnWidth(1, 13 * 256); sheet1.SetColumnWidth(2, 13 * 384); sheet1.SetColumnWidth(3, 13 * 256); sheet1.SetColumnWidth(4, 13 * 512); sheet1.SetColumnWidth(5, 13 * 256); sheet1.SetColumnWidth(6, 13 * 256); sheet1.SetColumnWidth(7, 13 * 256); //给sheet1添加第一行的头部标题 NPOI.SS.UserModel.IRow row1 = sheet1.CreateRow(0); row1.CreateCell(0).SetCellValue("姓名"); row1.CreateCell(1).SetCellValue("体检编号"); row1.CreateCell(2).SetCellValue("体检日期"); row1.CreateCell(3).SetCellValue("出生日期"); row1.CreateCell(4).SetCellValue("电话"); row1.CreateCell(5).SetCellValue("所属单位"); row1.CreateCell(6).SetCellValue("身份证"); row1.CreateCell(7).SetCellValue("年龄"); log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("11111111111111111111111111"); //将数据逐步写入sheet1各个行 for (int i = 0; i < list.Count; i++) { NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1); rowtemp.CreateCell(0).SetCellValue(list[i].person_name); rowtemp.CreateCell(1).SetCellValue(list[i].physical_num); rowtemp.CreateCell(2).SetCellValue(list[i].register_date); //if (list[i].birth != "") //{ rowtemp.CreateCell(3).SetCellValue(list[i].birth); //} //else //{ // rowtemp.CreateCell(1).SetCellValue(""); //} //if (list[i].phone.ToString() != "") //{ rowtemp.CreateCell(4).SetCellValue(list[i].phone); //} //else //{ // rowtemp.CreateCell(2).SetCellValue(""); //} rowtemp.CreateCell(5).SetCellValue(list[i].util_name); rowtemp.CreateCell(6).SetCellValue(list[i].card_number); rowtemp.CreateCell(7).SetCellValue(list[i].person_age); } log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("222222222222222222222"); // 写入到客户端 //System.IO.MemoryStream ms = new System.IO.MemoryStream(); //book.Write(ms); //ms.Seek(0, SeekOrigin.Begin); string fileName = "从业主检情况" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; string urlPath = "exp/" + fileName; string path = Server.MapPath("\\" + urlPath); string excelpath = System.Web.HttpContext.Current.Server.MapPath("Export/"); //path += fileName; FileStream fs = new FileStream(path, FileMode.Create); book.Write(fs); fs.Close(); log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("333333333333333333333"); var sql = ""; switch (sort) { case "1": sql = @"select id,health_certificate_number,enterprise_info_maintain_id,physical_num,person_name,person_age,card_number,phone,category,work_category,util_name,area,register_type,register_date from professionalExam_register where not exists(select 1 from professionalExam_project_result where (qualified = '不合格' or deficiency = '缺项') and person_id=professionalExam_register.id) and procedure_status = '已录入检查结果' and register_type <> '复检登记' and freezing_and_thawing is null and register_date >= '" + start + "' and register_date <= '" + end + "' and exam_type like'%从业%'" + "and trade_type_maintain_id=4"; break; case "2": sql = @"select id,health_certificate_number,enterprise_info_maintain_id,physical_num,person_name,person_age,card_number,phone,category,work_category,util_name,area,register_type,register_date from professionalExam_register where exists(select 1 from professionalExam_project_result where qualified = '不合格' and person_id=professionalExam_register.id) and procedure_status = '已录入检查结果' and register_type <> '复检登记' and freezing_and_thawing is null and register_date >= '" + start + "' and register_date <= '" + end + "' and exam_type like'%从业%'" + "and trade_type_maintain_id=4"; break; case "3": sql = @"select id,health_certificate_number,enterprise_info_maintain_id,physical_num,person_name,person_age,card_number,phone,category,work_category,util_name,area,register_type,register_date from professionalExam_register where exists(select distinct person_id from professionalExam_project_result where deficiency = '缺项' and person_id=professionalExam_register.id) and procedure_status = '已录入检查结果' and register_type <> '复检登记' and freezing_and_thawing is null and register_date >= '" + start + "' and register_date <= '" + end + "' and exam_type like'%从业%'" + "and trade_type_maintain_id=4"; break; case "4": sql = @"select id,health_certificate_number,enterprise_info_maintain_id,physical_num,person_name,person_age,card_number,phone,category,work_category,util_name,area,register_type,register_date from professionalExam_register where register_type = '复检登记' and procedure_status = '已录入检查结果' and freezing_and_thawing is null and register_date >= '" + start + "' and register_date <= '" + end + "' and exam_type like'%从业%'" + "and trade_type_maintain_id=4"; break; case "5": sql = @"select id,health_certificate_number,enterprise_info_maintain_id,physical_num,person_name,person_age,card_number,phone,category,work_category,util_name,area,register_type,register_date from professionalExam_register where procedure_status in('主检医生已审核','已打印健康证') and freezing_and_thawing is null and register_date >= '" + start + "' and register_date <= '" + end + "' and exam_type like'%从业%'" + "and trade_type_maintain_id=4"; break; } if (where != "") { sql += " and (person_name like '" + where + "' or physical_num like '" + where + "')"; } if (crowd != "" && crowd != null) { sql += " and category = '" + crowd + "'"; } sql += " order by register_date"; Hashtable MyTable = new Hashtable(); MyTable.Add("person_name", "姓名"); MyTable.Add("physical_num", "体检编号"); MyTable.Add("register_date", "体检日期"); MyTable.Add("birth", "出生日期"); MyTable.Add("phone", "电话"); MyTable.Add("util_name", "所属单位"); MyTable.Add("card_number", "身份证"); MyTable.Add("person_age", "年龄"); string strConn = WebConfigurationManager.ConnectionStrings["TJDB"].ConnectionString; ; //SqlConnection conn; //conn = new SqlConnection(strConn); //conn.Open(); //using (IDbConnection conn = CommHelper.GetSqlConnection()) //{ log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("444444444444444444444"); ZWL.Common.DataToExcel.GridViewToExcel(GetDataSetTJDB(sql, strConn), MyTable, "Excel报表"); //} return Json(new { State = 0, Message = "导出成功", Path = "/" + urlPath }); } catch (Exception ex) { return Json(new { State = 1, Message = "导出失败" + ex.Message }); } } public JsonResult getDataInspection2(string id) { if (string.IsNullOrEmpty(id)) return Json(null); var bll = new professionalExam_project_resultBll(); var result = bll.getPersonResult(id, ""); return Json(new { Rows = result }); } public JsonResult getOneInspection(string id) { if (string.IsNullOrEmpty(id)) return Json(null); var bll = new ProfessionalExamRegisterBll(); var result = bll.getOne(id); return Json(result, JsonRequestBehavior.AllowGet); } public ActionResult EmploymentInspectionLeak() { return View(); } public JsonResult GetLeakData(string start, string end, string type, string status, bool flag = false) { if (string.IsNullOrEmpty(start) || string.IsNullOrEmpty(end)) return Json(null, JsonRequestBehavior.AllowGet); var bll = new ProfessionalExamRegisterBll(); var result = bll.getClInfection(start, end, type, status, flag); return Json(new { Rows = result }, JsonRequestBehavior.AllowGet); } public bool op(string id, string sort, string zjjl, string zjjg) { if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(sort)) return false; var bll = new ProfessionalExamRegisterBll(); var result = bll.op(id, sort, zjjl, zjjg, Session["loginUser"] as Models.ERPUser); return result; } public bool opAll(string ids) { if (string.IsNullOrEmpty(ids)) return false; var bll = new ProfessionalExamRegisterBll(); var result = bll.opAll(ids.TrimEnd(','), Session["loginUser"] as Models.ERPUser); return result; } public bool opFj(string id, string zjjl, string zjjg, string items) { if (string.IsNullOrEmpty(id)) return false; var bll = new ProfessionalExamRegisterBll(); var result = bll.opFj(id, zjjl, zjjg, Session["loginUser"] as Models.ERPUser, items); return result; } public ActionResult EmploymentInspectionRepeat(string id) { ViewData["team"] = new SelectList(new ExamGroupMaintainBll().GetAllListTrue(""), "id", "team_name"); return View(Convert.ToInt32(id)); } public ActionResult getRepeatData(string teamid, string id) { var bll = new ExamProjectMaintainBll(); var result = bll.GetAllList2("", teamid, id); return Json(new { Rows = result }); } public ActionResult getRepeatData2(string id) { var bll = new ExamProjectMaintainBll(); var result = bll.GetAllList3("", id); return Json(new { Rows = result }); } public ActionResult EmploymentInspectionConclusion() { return View(); } public JsonResult getConclusionData() { var bll = new MainDoctorConclusionMaintainBll(); var result = bll.GetAllList("", "是"); return Json(new { Rows = result }); } public ActionResult EmploymentInspectionAbnormal(string id) { return View(Convert.ToInt32(id)); } public ActionResult getAbnormalData(string id) { if (string.IsNullOrEmpty(id)) return Json(null); var bll = new professionalExam_project_resultBll(); var result = bll.getPersonResult(id, "不合格"); return Json(new { Rows = result }); } //导出excel public JsonResult exportLeak(string start, string end, string type, string status, bool flag = false) { if (string.IsNullOrEmpty(start) || string.IsNullOrEmpty(end)) return Json(null, JsonRequestBehavior.AllowGet); var bll = new ProfessionalExamRegisterBll(); var result = bll.getCl(start, end, type, status, flag); DataTable dt = new DataTable(); dt.Columns.Add("体检编号"); dt.Columns.Add("姓名"); dt.Columns.Add("企业"); dt.Columns.Add("登记日期"); dt.Columns.Add("联系电话"); foreach (var m in result) { DataRow mdr = dt.NewRow(); mdr["体检编号"] = m.physical_num; mdr["姓名"] = m.person_name; mdr["企业"] = m.util_name; mdr["登记日期"] = m.register_date; mdr["联系电话"] = m.phone; dt.Rows.Add(mdr); } string file = Guid.NewGuid().ToString("N") + ".xlsx"; string path = Server.MapPath("~/exp/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } try { xiaoy.Excel.ExcelFile.SetData(dt, path + file, xiaoy.Excel.ExcelVersion.Excel12, xiaoy.Excel.HDRType.Yes); return Json(new { State = "1", Message = file }); } catch (Exception ex) { return Json(new { State = "0", Message = ex.Message }); } } public FileResult downLeak(string file) { string path = Server.MapPath("~/exp/"); if (file.EndsWith("drimp")) return File(path + file, "application/drimp", DateTime.Now.ToString("yyyyMMdd") + ".drimp"); if (file.EndsWith("xlsx")) return File(path + file, "application/Excel", DateTime.Now.ToString("yyyyMMdd") + ".xlsx"); if (file.EndsWith("syzip")) return File(path + file, "application/Zip", DateTime.Now.ToString("yyyyMMdd") + ".syzip"); return null; } #endregion #region /// /// 根据id获取数据 /// /// /// [AllowAnonymous] public string GetTypeByID_OpenUser() { string user_id = Session["InfectionUserID"].ToString(); return new BLL.InfectionOpenUserBll().GetTypeByID(user_id); } #endregion #region 体检预约操作 // GET: Inspection public ActionResult PhysicalExamination() { int monthOne = new InfectionTestBll().getMonthOne(); int monthTwo = new InfectionTestBll().getMonthTwo(); int allOne = new InfectionTestBll().getAllOne(); int allTwo = new InfectionTestBll().getAllTwo(); ViewBag.monthOne = monthOne; ViewBag.monthTwo = monthTwo; ViewBag.allOne = allOne; ViewBag.allTwo = allTwo; return View(); } public JsonResult getData(string pageSize, string page, string start, string end) { var bll = new InfectionTestBll(); List result = bll.getAllList(pageSize, page, start, end); int count = bll.getCount(start, end); System.Globalization.DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo(); dtFormat.ShortDatePattern = "yyyy/MM/dd"; //foreach (var m in result) //{ // DateTime date = Convert.ToDateTime("2011/05/26", dtFormat); // m.birth = date.ToString(); //} return Json(new { Total = count, Rows = result }); } //修改 public ActionResult PhysicalExaminationQuery(string id) { var al = new List() { new Droplist { Value = "0", Title = "已预约" }, new Droplist { Value = "1", Title = "已体检" } }; ViewData["state"] = new SelectList(al, "Value", "Title"); //ViewData["yszyb"] = new SelectList(new InfectionTestBll().GetAllList2(), "id", "state"); InfectionTestModel model; if (string.IsNullOrEmpty(id)) { model = new InfectionTestModel() { }; } else { model = new InfectionTestBll().getOne(id); } return View(model); } public ActionResult PhysicalExaminationQuerySave(InfectionTestModel model) { ModelState.Remove("id"); if (!ModelState.IsValid) { var errors = ModelState.Values.SelectMany(v => v.Errors); var al = new List() { new Droplist { Value = "0", Title = "已预约" }, new Droplist { Value = "1", Title = "已体检" } }; ViewData["ischeck"] = new SelectList(al, "Value", "Title"); return View(model); } InfectionTestBll bll = new InfectionTestBll(); return Json(bll.save(model)); } //取消预约 public ActionResult PhysicalExaminationAbolish(string id) { InfectionTestModel model; if (string.IsNullOrEmpty(id)) { model = new InfectionTestModel() { }; } else { model = new InfectionTestBll().getOne(id); } return View(model); } public ActionResult PhysicalExaminationAbolishSave(InfectionTestModel model) { ModelState.Remove("id"); if (!ModelState.IsValid) { return View(model); } InfectionTestBll bll = new InfectionTestBll(); return Json(bll.abolishOrder(model)); } //新增预约 public ActionResult PhysicalExaminationAdd(string name, string ident) { weixinBll wxBill = new weixinBll(); List jgList = wxBill.getyyjgs(); List itemList = new List(); foreach (tjjg info in jgList) { SelectListItem item = new SelectListItem() { Value = info.jgid.ToString(), Text = info.jgmc.ToString() }; itemList.Add(item); } SelectList select = new SelectList(itemList, "Value", "Text"); ViewBag.JGList = select; ViewBag.name = name; ViewBag.ident = ident; return View(); } //新增预约 public ActionResult PhysicalExaminationAddSave(InfectionTestModel model) { try { InfectionOpenUserInfoBll infoBll = new InfectionOpenUserInfoBll(); InfectionOpenUserInfoModel info = infoBll.GetInfoByIdent(model.ident); if (info != null) { model.info_id = info.id; model.birth = info.birth; model.phone = info.phone; model.unit = info.unit; model.create_time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); } else { return Json("请录入个人信息!"); } InfectionTestBll bll = new InfectionTestBll(); return Json(bll.save(model)); } catch { return Json("系统错误!"); } } //导出excel public JsonResult exportFile(string start, string end) { var result = new InfectionTestBll().export(start, end); DataTable dt = new DataTable(); dt.Columns.Add("姓名"); dt.Columns.Add("出生日期"); dt.Columns.Add("电话"); dt.Columns.Add("所属单位"); dt.Columns.Add("身份证"); dt.Columns.Add("预约时间"); dt.Columns.Add("体检状态"); foreach (var m in result) { DataRow mdr = dt.NewRow(); mdr["姓名"] = m.name; mdr["出生日期"] = m.birth; mdr["电话"] = m.phone; mdr["所属单位"] = m.unit; mdr["身份证"] = m.ident; mdr["预约时间"] = m.order_date; mdr["体检状态"] = m.userState; dt.Rows.Add(mdr); } string file = Guid.NewGuid().ToString("N") + ".xlsx"; string path = Server.MapPath("~/exp/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } try { xiaoy.Excel.ExcelFile.SetData(dt, path + file, xiaoy.Excel.ExcelVersion.Excel12, xiaoy.Excel.HDRType.Yes); return Json(new { State = "1", Message = file }); } catch (Exception ex) { return Json(new { State = "0", Message = ex.Message }); } } //导出excel public ActionResult Export(string start, string end) { try { var list = new InfectionTestBll().export(start, end); //创建Excel文件的对象 NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(); //添加一个sheet NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1"); sheet1.SetColumnWidth(0, 13 * 256); sheet1.SetColumnWidth(1, 13 * 256); sheet1.SetColumnWidth(2, 13 * 384); sheet1.SetColumnWidth(3, 13 * 256); sheet1.SetColumnWidth(4, 13 * 512); sheet1.SetColumnWidth(5, 13 * 256); sheet1.SetColumnWidth(6, 13 * 256); sheet1.SetColumnWidth(7, 13 * 256); //给sheet1添加第一行的头部标题 NPOI.SS.UserModel.IRow row1 = sheet1.CreateRow(0); row1.CreateCell(0).SetCellValue("姓名"); row1.CreateCell(1).SetCellValue("出生日期"); row1.CreateCell(2).SetCellValue("电话"); row1.CreateCell(3).SetCellValue("所属单位"); row1.CreateCell(4).SetCellValue("身份证"); row1.CreateCell(5).SetCellValue("预约时间"); row1.CreateCell(6).SetCellValue("预约状态"); row1.CreateCell(7).SetCellValue("体检状态"); //将数据逐步写入sheet1各个行 for (int i = 0; i < list.Count; i++) { NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1); rowtemp.CreateCell(0).SetCellValue(list[i].name.ToString()); if (list[i].birth.ToString() != "") { rowtemp.CreateCell(1).SetCellValue(list[i].birth.ToString()); } else { rowtemp.CreateCell(1).SetCellValue(""); } if (list[i].phone.ToString() != "") { rowtemp.CreateCell(2).SetCellValue(list[i].phone.ToString()); } else { rowtemp.CreateCell(2).SetCellValue(""); } rowtemp.CreateCell(3).SetCellValue(list[i].unit.ToString()); rowtemp.CreateCell(4).SetCellValue(list[i].ident.ToString()); rowtemp.CreateCell(5).SetCellValue(list[i].order_date.ToString()); string state = ""; if (list[i].state.ToString() == "0") { state = "已预约"; } if (list[i].state.ToString() == "1") { state = "已体检"; } if (list[i].state.ToString() == "2") { state = "已取消"; } rowtemp.CreateCell(6).SetCellValue(state); string status = ""; if (list[i].status == "0") { status = "未体检"; } if (list[i].status == "1") { status = "已体检"; } rowtemp.CreateCell(7).SetCellValue(status); } // 写入到客户端 //System.IO.MemoryStream ms = new System.IO.MemoryStream(); //book.Write(ms); //ms.Seek(0, SeekOrigin.Begin); string fileName = "体检预约情况" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; string urlPath = "exp/" + fileName; string path = Server.MapPath("\\" + urlPath); string excelpath = System.Web.HttpContext.Current.Server.MapPath("Export/"); //path += fileName; FileStream fs = new FileStream(path, FileMode.Create); book.Write(fs); fs.Close(); string sql = "select t.*,case when t.state=0 then '已预约' when t.state=1 then '已体检' when t.state=2 then '已取消' end as userState,case when m.status=0 then '未体检' when m.status=1 then '已体检' end as status from infection_test t left join MedicalAppointment m on t.ma_id=m.id where 1=1 "; if (!string.IsNullOrEmpty(start)) { sql += " and order_date >= '" + start + "' "; } if (!string.IsNullOrEmpty(end)) { sql += "' and order_date <= '" + end + "' "; } Hashtable MyTable = new Hashtable(); MyTable.Add("name", "姓名"); MyTable.Add("birth", "出生日期"); MyTable.Add("phone", "电话"); MyTable.Add("unit", "所属单位"); MyTable.Add("ident", "身份证"); MyTable.Add("order_date", "预约时间"); MyTable.Add("userState", "预约状态"); MyTable.Add("status", "体检状态"); string strConn = WebConfigurationManager.ConnectionStrings["TJDB"].ConnectionString; ; //SqlConnection conn; //conn = new SqlConnection(strConn); //conn.Open(); //using (IDbConnection conn = CommHelper.GetSqlConnection()) //{ ZWL.Common.DataToExcel.GridViewToExcel(GetDataSetTJDB(sql, strConn), MyTable, "Excel报表"); //} return Json(new { State = 0, Message = "导出成功", Path = "/" + urlPath }); } catch (Exception ex) { return Json(new { State = 1, Message = "导出失败" + ex.Message }); } } //导出excel public ActionResult exportQuestion(string name, string ident, string tjxx) { try { var list = new InfectionQuestionAnswerBll().export(name, ident); //创建Excel文件的对象 NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(); //添加一个sheet NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1"); sheet1.SetColumnWidth(0, 13 * 256); sheet1.SetColumnWidth(1, 13 * 256); sheet1.SetColumnWidth(2, 13 * 384); sheet1.SetColumnWidth(3, 13 * 256); sheet1.SetColumnWidth(4, 13 * 512); sheet1.SetColumnWidth(5, 13 * 256); sheet1.SetColumnWidth(6, 13 * 256); sheet1.SetColumnWidth(7, 13 * 256); sheet1.SetColumnWidth(8, 13 * 256); sheet1.SetColumnWidth(9, 13 * 256); sheet1.SetColumnWidth(10, 13 * 256); sheet1.SetColumnWidth(11, 13 * 256); sheet1.SetColumnWidth(12, 13 * 256); sheet1.SetColumnWidth(13, 13 * 256); sheet1.SetColumnWidth(14, 13 * 256); sheet1.SetColumnWidth(15, 13 * 256); sheet1.SetColumnWidth(16, 13 * 256); sheet1.SetColumnWidth(17, 13 * 256); sheet1.SetColumnWidth(18, 13 * 256); sheet1.SetColumnWidth(19, 13 * 256); sheet1.SetColumnWidth(20, 13 * 256); sheet1.SetColumnWidth(21, 13 * 256); sheet1.SetColumnWidth(22, 13 * 256); sheet1.SetColumnWidth(23, 13 * 256); sheet1.SetColumnWidth(24, 13 * 256); sheet1.SetColumnWidth(25, 13 * 256); sheet1.SetColumnWidth(26, 13 * 256); sheet1.SetColumnWidth(27, 13 * 256); sheet1.SetColumnWidth(28, 13 * 256); sheet1.SetColumnWidth(29, 13 * 256); sheet1.SetColumnWidth(30, 13 * 256); sheet1.SetColumnWidth(31, 13 * 256); sheet1.SetColumnWidth(32, 13 * 256); sheet1.SetColumnWidth(33, 13 * 256); sheet1.SetColumnWidth(34, 13 * 256); sheet1.SetColumnWidth(35, 13 * 256); sheet1.SetColumnWidth(36, 13 * 256); sheet1.SetColumnWidth(37, 13 * 256); sheet1.SetColumnWidth(38, 13 * 256); sheet1.SetColumnWidth(39, 13 * 256); sheet1.SetColumnWidth(40, 13 * 256); sheet1.SetColumnWidth(41, 13 * 256); sheet1.SetColumnWidth(42, 13 * 256); sheet1.SetColumnWidth(43, 13 * 256); sheet1.SetColumnWidth(44, 13 * 256); sheet1.SetColumnWidth(45, 13 * 256); sheet1.SetColumnWidth(46, 13 * 256); sheet1.SetColumnWidth(47, 13 * 256); sheet1.SetColumnWidth(48, 13 * 256); sheet1.SetColumnWidth(49, 13 * 256); sheet1.SetColumnWidth(50, 13 * 256); sheet1.SetColumnWidth(51, 13 * 256); sheet1.SetColumnWidth(52, 13 * 256); sheet1.SetColumnWidth(53, 13 * 256); sheet1.SetColumnWidth(54, 13 * 256); sheet1.SetColumnWidth(55, 13 * 256); sheet1.SetColumnWidth(56, 13 * 256); sheet1.SetColumnWidth(57, 13 * 256); sheet1.SetColumnWidth(58, 13 * 256); sheet1.SetColumnWidth(59, 13 * 256); sheet1.SetColumnWidth(60, 13 * 256); sheet1.SetColumnWidth(61, 13 * 256); sheet1.SetColumnWidth(62, 13 * 256); sheet1.SetColumnWidth(63, 13 * 256); sheet1.SetColumnWidth(64, 13 * 256); sheet1.SetColumnWidth(65, 13 * 256); sheet1.SetColumnWidth(66, 13 * 256); sheet1.SetColumnWidth(67, 13 * 256); sheet1.SetColumnWidth(68, 13 * 256); sheet1.SetColumnWidth(69, 13 * 256); sheet1.SetColumnWidth(70, 13 * 256); sheet1.SetColumnWidth(71, 13 * 256); sheet1.SetColumnWidth(72, 13 * 256); sheet1.SetColumnWidth(73, 13 * 256); sheet1.SetColumnWidth(74, 13 * 256); sheet1.SetColumnWidth(75, 13 * 256); sheet1.SetColumnWidth(76, 13 * 256); sheet1.SetColumnWidth(77, 13 * 256); sheet1.SetColumnWidth(78, 13 * 256); sheet1.SetColumnWidth(79, 13 * 256); sheet1.SetColumnWidth(80, 13 * 256); sheet1.SetColumnWidth(81, 13 * 256); sheet1.SetColumnWidth(82, 13 * 256); sheet1.SetColumnWidth(83, 13 * 256); sheet1.SetColumnWidth(84, 13 * 256); sheet1.SetColumnWidth(85, 13 * 256); sheet1.SetColumnWidth(86, 13 * 256); sheet1.SetColumnWidth(87, 13 * 256); sheet1.SetColumnWidth(88, 13 * 256); sheet1.SetColumnWidth(89, 13 * 256); sheet1.SetColumnWidth(90, 13 * 256); sheet1.SetColumnWidth(91, 13 * 256); sheet1.SetColumnWidth(92, 13 * 256); sheet1.SetColumnWidth(93, 13 * 256); sheet1.SetColumnWidth(94, 13 * 256); sheet1.SetColumnWidth(95, 13 * 256); sheet1.SetColumnWidth(96, 13 * 256); sheet1.SetColumnWidth(97, 13 * 256); sheet1.SetColumnWidth(98, 13 * 256); sheet1.SetColumnWidth(99, 13 * 256); sheet1.SetColumnWidth(100, 13 * 256); sheet1.SetColumnWidth(101, 13 * 256); sheet1.SetColumnWidth(102, 13 * 256); sheet1.SetColumnWidth(103, 13 * 256); sheet1.SetColumnWidth(104, 13 * 256); sheet1.SetColumnWidth(105, 13 * 256); sheet1.SetColumnWidth(106, 13 * 256); sheet1.SetColumnWidth(107, 13 * 256); sheet1.SetColumnWidth(108, 13 * 256); sheet1.SetColumnWidth(109, 13 * 256); sheet1.SetColumnWidth(110, 13 * 256); sheet1.SetColumnWidth(111, 13 * 256); //sheet1.SetColumnWidth(112, 13 * 256); //sheet1.SetColumnWidth(113, 13 * 256); //sheet1.SetColumnWidth(114, 13 * 256); //给sheet1添加第一行的头部标题 NPOI.SS.UserModel.IRow row1 = sheet1.CreateRow(0); row1.CreateCell(0).SetCellValue("姓名"); row1.CreateCell(1).SetCellValue("出生日期"); row1.CreateCell(2).SetCellValue("电话"); row1.CreateCell(3).SetCellValue("所属单位"); row1.CreateCell(4).SetCellValue("身份证"); row1.CreateCell(5).SetCellValue("A01"); row1.CreateCell(6).SetCellValue("A02"); row1.CreateCell(7).SetCellValue("A03"); row1.CreateCell(8).SetCellValue("B01"); row1.CreateCell(9).SetCellValue("B01_Q"); row1.CreateCell(10).SetCellValue("B02"); row1.CreateCell(11).SetCellValue("B03"); row1.CreateCell(12).SetCellValue("B04"); row1.CreateCell(13).SetCellValue("B05"); row1.CreateCell(14).SetCellValue("B06"); row1.CreateCell(15).SetCellValue("C01"); row1.CreateCell(16).SetCellValue("C01_Q"); row1.CreateCell(17).SetCellValue("C02"); row1.CreateCell(18).SetCellValue("C02_Q"); row1.CreateCell(19).SetCellValue("C03"); row1.CreateCell(20).SetCellValue("C04"); row1.CreateCell(21).SetCellValue("C05"); row1.CreateCell(22).SetCellValue("C06"); row1.CreateCell(23).SetCellValue("C07"); row1.CreateCell(24).SetCellValue("D01"); row1.CreateCell(25).SetCellValue("D02"); row1.CreateCell(26).SetCellValue("D02_Q"); row1.CreateCell(27).SetCellValue("D03"); row1.CreateCell(28).SetCellValue("D04"); row1.CreateCell(29).SetCellValue("D05"); row1.CreateCell(30).SetCellValue("E01"); row1.CreateCell(31).SetCellValue("E02"); row1.CreateCell(32).SetCellValue("E03"); row1.CreateCell(33).SetCellValue("E04"); row1.CreateCell(34).SetCellValue("F01"); row1.CreateCell(35).SetCellValue("F01_Q"); row1.CreateCell(36).SetCellValue("F02"); row1.CreateCell(37).SetCellValue("F03"); row1.CreateCell(38).SetCellValue("F04"); row1.CreateCell(39).SetCellValue("F05"); row1.CreateCell(40).SetCellValue("F06"); row1.CreateCell(41).SetCellValue("F06_Q"); row1.CreateCell(42).SetCellValue("F07"); row1.CreateCell(43).SetCellValue("F08"); row1.CreateCell(44).SetCellValue("F09"); row1.CreateCell(45).SetCellValue("G01"); row1.CreateCell(46).SetCellValue("G02"); row1.CreateCell(47).SetCellValue("G03"); row1.CreateCell(48).SetCellValue("G04"); row1.CreateCell(49).SetCellValue("G05"); row1.CreateCell(50).SetCellValue("G06"); row1.CreateCell(51).SetCellValue("G06_Q"); row1.CreateCell(52).SetCellValue("G07"); row1.CreateCell(53).SetCellValue("G08"); row1.CreateCell(54).SetCellValue("G08_Q"); row1.CreateCell(55).SetCellValue("G09"); row1.CreateCell(56).SetCellValue("G10"); row1.CreateCell(57).SetCellValue("G11"); row1.CreateCell(58).SetCellValue("G11_Q"); row1.CreateCell(59).SetCellValue("G12"); row1.CreateCell(60).SetCellValue("G13"); row1.CreateCell(61).SetCellValue("G13_Q"); row1.CreateCell(62).SetCellValue("G14"); row1.CreateCell(63).SetCellValue("G15"); row1.CreateCell(64).SetCellValue("H01"); row1.CreateCell(65).SetCellValue("H02"); row1.CreateCell(66).SetCellValue("H02_Q"); row1.CreateCell(67).SetCellValue("H03"); row1.CreateCell(68).SetCellValue("H03_Q"); row1.CreateCell(69).SetCellValue("H04"); row1.CreateCell(70).SetCellValue("H04_Q"); row1.CreateCell(71).SetCellValue("H05"); row1.CreateCell(72).SetCellValue("H05_Q"); row1.CreateCell(73).SetCellValue("H06"); row1.CreateCell(74).SetCellValue("H07"); row1.CreateCell(75).SetCellValue("H08"); row1.CreateCell(76).SetCellValue("H08_Q"); row1.CreateCell(77).SetCellValue("H09"); row1.CreateCell(78).SetCellValue("H10"); row1.CreateCell(79).SetCellValue("H11"); row1.CreateCell(80).SetCellValue("H11_Q"); row1.CreateCell(81).SetCellValue("H12"); row1.CreateCell(82).SetCellValue("H13"); row1.CreateCell(83).SetCellValue("H13_Q"); row1.CreateCell(84).SetCellValue("H14"); row1.CreateCell(85).SetCellValue("H15"); row1.CreateCell(86).SetCellValue("I01"); row1.CreateCell(87).SetCellValue("I02"); row1.CreateCell(88).SetCellValue("I02_Q"); row1.CreateCell(89).SetCellValue("I03"); row1.CreateCell(90).SetCellValue("I03_Q"); row1.CreateCell(91).SetCellValue("J01"); row1.CreateCell(92).SetCellValue("J02"); row1.CreateCell(93).SetCellValue("J03"); row1.CreateCell(94).SetCellValue("J04"); row1.CreateCell(95).SetCellValue("J05"); row1.CreateCell(96).SetCellValue("J06"); row1.CreateCell(97).SetCellValue("J07"); row1.CreateCell(98).SetCellValue("J08"); row1.CreateCell(99).SetCellValue("K01"); row1.CreateCell(100).SetCellValue("K02"); row1.CreateCell(101).SetCellValue("K03"); row1.CreateCell(102).SetCellValue("K04"); row1.CreateCell(103).SetCellValue("K05"); row1.CreateCell(104).SetCellValue("K06"); row1.CreateCell(105).SetCellValue("K07"); row1.CreateCell(106).SetCellValue("K08"); row1.CreateCell(107).SetCellValue("K09"); row1.CreateCell(108).SetCellValue("K10"); row1.CreateCell(109).SetCellValue("T01"); row1.CreateCell(110).SetCellValue("T02a"); row1.CreateCell(111).SetCellValue("T02b"); //row1.CreateCell(112).SetCellValue("T03"); //row1.CreateCell(113).SetCellValue("T03_Q"); //row1.CreateCell(114).SetCellValue("T03_Q2"); //将数据逐步写入sheet1各个行 for (int i = 0; i < list.Count; i++) { NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1); rowtemp.CreateCell(0).SetCellValue(list[i].name.ToString()); if (list[i].birth.ToString() != "") { rowtemp.CreateCell(1).SetCellValue(list[i].birth.ToString()); } else { rowtemp.CreateCell(1).SetCellValue(""); } if (list[i].phone.ToString() != "") { rowtemp.CreateCell(2).SetCellValue(list[i].phone.ToString()); } else { rowtemp.CreateCell(2).SetCellValue(""); } rowtemp.CreateCell(3).SetCellValue(list[i].unit.ToString()); rowtemp.CreateCell(4).SetCellValue(list[i].ident.ToString()); rowtemp.CreateCell(5).SetCellValue(list[i].A01.ToString()); rowtemp.CreateCell(6).SetCellValue(list[i].A02.ToString()); rowtemp.CreateCell(7).SetCellValue(list[i].A03.ToString()); rowtemp.CreateCell(8).SetCellValue(list[i].B01.ToString()); rowtemp.CreateCell(9).SetCellValue(list[i].B01_Q.ToString()); rowtemp.CreateCell(10).SetCellValue(list[i].B02.ToString()); rowtemp.CreateCell(11).SetCellValue(list[i].B03.ToString()); rowtemp.CreateCell(12).SetCellValue(list[i].B04.ToString()); rowtemp.CreateCell(13).SetCellValue(list[i].B05.ToString()); rowtemp.CreateCell(14).SetCellValue(list[i].B06.ToString()); rowtemp.CreateCell(15).SetCellValue(list[i].C01.ToString()); rowtemp.CreateCell(16).SetCellValue(list[i].C01_Q.ToString()); rowtemp.CreateCell(17).SetCellValue(list[i].C02.ToString()); rowtemp.CreateCell(18).SetCellValue(list[i].C02_Q.ToString()); rowtemp.CreateCell(19).SetCellValue(list[i].C03.ToString()); rowtemp.CreateCell(20).SetCellValue(list[i].C04.ToString()); rowtemp.CreateCell(21).SetCellValue(list[i].C05.ToString()); rowtemp.CreateCell(22).SetCellValue(list[i].C06.ToString()); rowtemp.CreateCell(23).SetCellValue(list[i].C07.ToString()); rowtemp.CreateCell(24).SetCellValue(list[i].D01.ToString()); rowtemp.CreateCell(25).SetCellValue(list[i].D02.ToString()); rowtemp.CreateCell(26).SetCellValue(list[i].D02_Q.ToString()); rowtemp.CreateCell(27).SetCellValue(list[i].D03.ToString()); rowtemp.CreateCell(28).SetCellValue(list[i].D04.ToString()); rowtemp.CreateCell(29).SetCellValue(list[i].D05.ToString()); rowtemp.CreateCell(30).SetCellValue(list[i].E01.ToString()); rowtemp.CreateCell(31).SetCellValue(list[i].E02.ToString()); rowtemp.CreateCell(32).SetCellValue(list[i].E03.ToString()); rowtemp.CreateCell(33).SetCellValue(list[i].E04.ToString()); rowtemp.CreateCell(34).SetCellValue(list[i].F01.ToString()); rowtemp.CreateCell(35).SetCellValue(list[i].F01_Q.ToString()); rowtemp.CreateCell(36).SetCellValue(list[i].F02.ToString()); rowtemp.CreateCell(37).SetCellValue(list[i].F03.ToString()); rowtemp.CreateCell(38).SetCellValue(list[i].F04.ToString()); rowtemp.CreateCell(39).SetCellValue(list[i].F05.ToString()); rowtemp.CreateCell(40).SetCellValue(list[i].F06.ToString()); rowtemp.CreateCell(41).SetCellValue(list[i].F06_Q.ToString()); rowtemp.CreateCell(42).SetCellValue(list[i].F07.ToString()); rowtemp.CreateCell(43).SetCellValue(list[i].F08.ToString()); rowtemp.CreateCell(44).SetCellValue(list[i].F09.ToString()); rowtemp.CreateCell(45).SetCellValue(list[i].G01.ToString()); rowtemp.CreateCell(46).SetCellValue(list[i].G02.ToString()); rowtemp.CreateCell(47).SetCellValue(list[i].G03.ToString()); rowtemp.CreateCell(48).SetCellValue(list[i].G04.ToString()); rowtemp.CreateCell(49).SetCellValue(list[i].G05.ToString()); rowtemp.CreateCell(50).SetCellValue(list[i].G06.ToString()); rowtemp.CreateCell(51).SetCellValue(list[i].G06_Q.ToString()); rowtemp.CreateCell(52).SetCellValue(list[i].G07.ToString()); rowtemp.CreateCell(53).SetCellValue(list[i].G08.ToString()); rowtemp.CreateCell(54).SetCellValue(list[i].G08_Q.ToString()); rowtemp.CreateCell(55).SetCellValue(list[i].G09.ToString()); rowtemp.CreateCell(56).SetCellValue(list[i].G10.ToString()); rowtemp.CreateCell(57).SetCellValue(list[i].G11.ToString()); rowtemp.CreateCell(58).SetCellValue(list[i].G11_Q.ToString()); rowtemp.CreateCell(59).SetCellValue(list[i].G12.ToString()); rowtemp.CreateCell(60).SetCellValue(list[i].G13.ToString()); rowtemp.CreateCell(61).SetCellValue(list[i].G13_Q.ToString()); rowtemp.CreateCell(62).SetCellValue(list[i].G14.ToString()); rowtemp.CreateCell(63).SetCellValue(list[i].G15.ToString()); rowtemp.CreateCell(64).SetCellValue(list[i].H01.ToString()); rowtemp.CreateCell(65).SetCellValue(list[i].H02.ToString()); rowtemp.CreateCell(66).SetCellValue(list[i].H02_Q.ToString()); rowtemp.CreateCell(67).SetCellValue(list[i].H03.ToString()); rowtemp.CreateCell(68).SetCellValue(list[i].H03_Q.ToString()); rowtemp.CreateCell(69).SetCellValue(list[i].H04.ToString()); rowtemp.CreateCell(70).SetCellValue(list[i].H04_Q.ToString()); rowtemp.CreateCell(71).SetCellValue(list[i].H05.ToString()); rowtemp.CreateCell(72).SetCellValue(list[i].H05_Q.ToString()); rowtemp.CreateCell(73).SetCellValue(list[i].H06.ToString()); rowtemp.CreateCell(74).SetCellValue(list[i].H07.ToString()); rowtemp.CreateCell(75).SetCellValue(list[i].H08.ToString()); rowtemp.CreateCell(76).SetCellValue(list[i].H08_Q.ToString()); rowtemp.CreateCell(77).SetCellValue(list[i].H09.ToString()); rowtemp.CreateCell(78).SetCellValue(list[i].H10.ToString()); rowtemp.CreateCell(79).SetCellValue(list[i].H11.ToString()); rowtemp.CreateCell(80).SetCellValue(list[i].H11_Q.ToString()); rowtemp.CreateCell(81).SetCellValue(list[i].H12.ToString()); rowtemp.CreateCell(82).SetCellValue(list[i].H13.ToString()); rowtemp.CreateCell(83).SetCellValue(list[i].H13_Q.ToString()); rowtemp.CreateCell(84).SetCellValue(list[i].H14.ToString()); rowtemp.CreateCell(85).SetCellValue(list[i].H15.ToString()); rowtemp.CreateCell(86).SetCellValue(list[i].I01.ToString()); rowtemp.CreateCell(87).SetCellValue(list[i].I02.ToString()); rowtemp.CreateCell(88).SetCellValue(list[i].I02_Q.ToString()); rowtemp.CreateCell(89).SetCellValue(list[i].I03.ToString()); rowtemp.CreateCell(90).SetCellValue(list[i].I03_Q.ToString()); rowtemp.CreateCell(91).SetCellValue(list[i].J01.ToString()); rowtemp.CreateCell(92).SetCellValue(list[i].J02.ToString()); rowtemp.CreateCell(93).SetCellValue(list[i].J03.ToString()); rowtemp.CreateCell(94).SetCellValue(list[i].J04.ToString()); rowtemp.CreateCell(95).SetCellValue(list[i].J05.ToString()); rowtemp.CreateCell(96).SetCellValue(list[i].J06.ToString()); rowtemp.CreateCell(97).SetCellValue(list[i].J07.ToString()); rowtemp.CreateCell(98).SetCellValue(list[i].J08.ToString()); rowtemp.CreateCell(99).SetCellValue(list[i].K01.ToString()); rowtemp.CreateCell(100).SetCellValue(list[i].K02.ToString()); rowtemp.CreateCell(101).SetCellValue(list[i].K03.ToString()); rowtemp.CreateCell(102).SetCellValue(list[i].K04.ToString()); rowtemp.CreateCell(103).SetCellValue(list[i].K05.ToString()); rowtemp.CreateCell(104).SetCellValue(list[i].K06.ToString()); rowtemp.CreateCell(105).SetCellValue(list[i].K07.ToString()); rowtemp.CreateCell(106).SetCellValue(list[i].K08.ToString()); rowtemp.CreateCell(107).SetCellValue(list[i].K09.ToString()); rowtemp.CreateCell(108).SetCellValue(list[i].K10.ToString()); rowtemp.CreateCell(109).SetCellValue(list[i].T01.ToString()); rowtemp.CreateCell(110).SetCellValue(list[i].T02a.ToString()); rowtemp.CreateCell(111).SetCellValue(list[i].T02b.ToString()); //rowtemp.CreateCell(112).SetCellValue(list[i].T03.ToString()); //rowtemp.CreateCell(113).SetCellValue(list[i].T03_Q.ToString()); //rowtemp.CreateCell(114).SetCellValue(list[i].T03_Q2.ToString()); } // 写入到客户端 if (!string.IsNullOrEmpty(tjxx) && tjxx == "true") { //DataTable tjxxdt = new DataTable(); var tjxmdt = new DAL.ExamProjectResultMaintainDal().gettjlx4xm();// dal row1 = sheet1.GetRow(0); for (int h = 0; h < tjxmdt.Rows.Count; h++) { var ctj = row1.CreateCell(h + 112); ctj.SetCellValue(tjxmdt.Rows[h]["project_name"].ToString()); sheet1.SetColumnWidth(h + 112, 13 * 256); } for (int i = 1; i <= list.Count; i++) { row1 = sheet1.GetRow(i); DataTable tjjg= new DAL.professionalExam_project_resultDal().gettjjg(list[i-1].ident); for (int j=0;j< tjxmdt.Rows.Count;j++) { var ctj = row1.CreateCell(j + 112); var rows = tjjg.Select("project_id='" + tjxmdt.Rows[j]["project_id"].ToString() + "'"); if(rows.Length>0) ctj.SetCellValue(rows[0]["project_result"].ToString()); } } } string fileName = "问卷调查" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; string urlPath = "exp/" + fileName; string path = Server.MapPath("~/" + urlPath); string excelpath = System.Web.HttpContext.Current.Server.MapPath("~/Export/"); //path += fileName; FileStream fs = new FileStream(path, FileMode.Create); book.Write(fs); fs.Close(); return Json(new { State = 0, Message = "导出成功", Path = Url.Content("~/" + urlPath) }); } catch (Exception ex) { return Json(new { State = 1, Message = "导出失败" + ex.Message }); } } // 公有方法,获取数据,返回一个DataSet。 public static DataSet GetDataSetTJDB(string SqlString, string connString) { using (SqlConnection connection = new SqlConnection(connString)) { connection.Open(); using (SqlCommand cmd = new SqlCommand(SqlString, connection)) { using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { DataSet ds = new DataSet(); try { da.Fill(ds, "ds"); cmd.Parameters.Clear(); } catch (System.Data.SqlClient.SqlException ex) { throw new Exception(ex.Message); } connection.Close(); return ds; } } } } public void OutputClient(byte[] bytes) { HttpResponse response = System.Web.HttpContext.Current.Response; response.Buffer = true; response.Clear(); response.ClearHeaders(); response.ClearContent(); response.ContentType = "application/vnd.ms-excel"; response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}.xls", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"))); response.Charset = "GB2312"; response.ContentEncoding = Encoding.GetEncoding("GB2312"); response.BinaryWrite(bytes); response.Flush(); response.Close(); } public FileResult down(string file) { string path = Server.MapPath("~/exp/"); if (file.EndsWith("drimp")) return File(file, "application/drimp", DateTime.Now.ToString("yyyyMMdd") + ".drimp"); if (file.EndsWith("xls")) return File(file, "application/Excel", DateTime.Now.ToString("yyyyMMdd") + ".xls"); if (file.EndsWith("syzip")) return File(file, "application/Zip", DateTime.Now.ToString("yyyyMMdd") + ".syzip"); return null; } #endregion #region 个人信息审核操作 // GET: Inspection public ActionResult InformationAudit() { List list = new InfectionOpenUserInfoBll().GetDataAllByState(); List itemList = new List(); foreach (InfectionOpenUserInfoModel info in list) { SelectListItem item = new SelectListItem() { Value = info.id.ToString(), Text = info.name.ToString() }; itemList.Add(item); } SelectList select = new SelectList(itemList, "Value", "Text"); int monthPass = new InfectionOpenUserInfoBll().getMonthPass(); int monthRefuse = new InfectionOpenUserInfoBll().getMonthRefuse(); int allPass = new InfectionOpenUserInfoBll().getAllPass(); int allRefuse = new InfectionOpenUserInfoBll().getAllRefuse(); ViewBag.monthPass = monthPass; ViewBag.monthRefuse = monthRefuse; ViewBag.allPass = allPass; ViewBag.allRefuse = allRefuse; ViewBag.UserNameList = select; return View(); } public ActionResult QuestionnaireAdd() { return View(); } public JsonResult getData_InformationAudit(int page, int pagesize, string name, string unit, string phone, string ident) { var bll = new InfectionOpenUserInfoBll(); List result = bll.getAllList(page, pagesize, name, unit, phone, ident); int count = bll.getCounts(name, unit, phone, ident); List list = new InfectionOpenUserInfoBll().GetDataAllByState(); List itemList = new List(); ERPUserBll ErpBll = new ERPUserBll(); for (int i = 0; i < result.Count; i++) { string trueName = ErpBll.GetTrueNameById(result[i].pass_by); result[i].oa_trueName = trueName; } foreach (InfectionOpenUserInfoModel info in list) { SelectListItem item = new SelectListItem() { Value = info.id.ToString(), Text = info.name.ToString() }; itemList.Add(item); } SelectList select = new SelectList(itemList, "Value", "Text"); ViewBag.UserNameList = select; return Json(new { Total = count, Rows = result }); } //发送红包 public ActionResult sendRedPackView(string openid, string id) { ViewBag.openid = openid; ViewBag.id = id; return View(); } //发送红包 public ActionResult sendRedPack(string openid, string amount, string id) { try { double dm = double.Parse(amount); dm = Math.Round(dm, 2); int m = (int)(dm * 100); infectionRedMoneyBll mBill = new infectionRedMoneyBll(); InfectionRedBll bill = new InfectionRedBll(); infectionRedMoneyModel mModel = mBill.getInitData(); InfectionOpenUserInfoBll infobll = new InfectionOpenUserInfoBll(); InfectionOpenUserInfoModel infomodel = infobll.findById(int.Parse(id)); if (mModel.questionnairemoney > 0) { if (infomodel != null && infomodel.user_id != 0) { int iMin = 1000; int iMax = 9999; Random rd = new Random();//构造随机数 string strMch_billno = Common.Global.InfectionMchId + DateTime.Now.ToString("yyyyMMddHHmmss") + rd.Next(iMin, iMax).ToString(); InfectionOpenUserModel openuser = new InfectionOpenUserBll().GetDataByID(infomodel.user_id.ToString()); InfectionRedModel redmodel = new InfectionRedModel(); redmodel.openid = openuser.openid; redmodel.phone = infomodel.phone; redmodel.sum = mModel.questionnairemoney; redmodel.state = 0; redmodel.create_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); redmodel.type = 4; redmodel.mch_billno = strMch_billno; int redresult = bill.InsertRed(redmodel); //log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("redresult=====================" + redresult); InfectionWXController wxcontroller = new InfectionWXController(); //bool redcode = wxcontroller.sendRedPack(openuser.openid, (int)(mModel.questionnairemoney * 100)); string redcode = new InfectionWXController().sendRedPack(openid, m, strMch_billno); //log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("redcode1=====================" + redcode); if (!string.IsNullOrEmpty(redcode)) { //log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("redcode2=====================" + redcode); int b = bill.UpdateState(redresult.ToString(), redcode); //log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("b=====================" + b); int a = new InfectionOpenUserInfoBll().UpdateRecommendStateById(id); //log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("a=====================" + a); if (a > 0) { return Json(new { Message = "发送成功" }); } return Json(new { Message = "发送失败" }); } return Json(new { Message = "发送失败" }); } return Json(new { Message = "发送失败" }); } return Json(new { Message = "发送失败" }); } catch (Exception ex) { log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("exception=====================" + ex.Message); return Json(ex); } } //详情 public ActionResult InformationAuditDetails(string id) { if (string.IsNullOrEmpty(id)) return Json(null); var bll = new InfectionOpenUserInfoBll(); if (id != "") { List list = new InfectionOpenCrowdBll().GetOpenDataList(); List itemList = new List(); foreach (InfectionOpenCrowdModel crowd in list) { SelectListItem item = new SelectListItem() { Value = crowd.id.ToString(), Text = crowd.name.ToString() }; itemList.Add(item); } SelectList select = new SelectList(itemList, "Value", "Text"); ViewBag.crowdList = select; string url = Request.Url.ToString().Replace(Request.RawUrl.ToString(), ""); var model = bll.getOne(id); var viewModel = new InfectionOpenUserInfoModel { id = model.id, name = model.name, ident = model.ident, phone = model.phone, type = model.type, pass_name = model.pass_name, pass_time = model.pass_time, birth = model.birth, unit = model.unit, crowd_id = model.crowd_id, license = url + "/dccdc" + model.license }; return View(viewModel); } else { return View(); } } //修改 public ActionResult InformationAuditModify(string id) { List list = new InfectionOpenCrowdBll().GetOpenDataList(); List itemList = new List(); foreach (InfectionOpenCrowdModel crowd in list) { SelectListItem item = new SelectListItem() { Value = crowd.id.ToString(), Text = crowd.name.ToString() }; itemList.Add(item); } SelectList select = new SelectList(itemList, "Value", "Text"); ViewBag.crowdList = select; InfectionOpenUserInfoModel model; if (string.IsNullOrEmpty(id)) { model = new InfectionOpenUserInfoModel() { }; } else { model = new InfectionOpenUserInfoBll().getOne(id); ViewBag.src = Request.Url.ToString().Replace(Request.RawUrl.ToString(), "") + "/dccdc" + model.license; } return View(model); } //保存 public ActionResult InformationAuditModifySave(InfectionOpenUserInfoModel model) { string address = string.Empty; if (model.investigationState == "0") { if (Request.Files.Count != 0) { string s = Request.Files.GetType().ToString(); string path = string.Empty; try { path = Server.MapPath("~/photo/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string specificDate = DateTime.Now.ToString("yyyyMMdd").ToString(); path += specificDate + "/"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } address = DateTime.Now.ToString("HHmmss") + "-" + Guid.NewGuid().ToString() + ".jpg"; path += address; Request.Files[0].SaveAs(path); address = "/photo/" + specificDate + "/" + address; } catch { } } } InfectionOpenUserInfoBll bll = new InfectionOpenUserInfoBll(); model.license = address; model.type = 0; model.create_time = DateTime.Now.ToString(); return Json(bll.save(model)); } //审核 public JsonResult audit(string id, string type, string reason, string pass_by) { var bll = new InfectionOpenUserInfoBll(); DateTime createTime = System.DateTime.Now; ERPUser erpUser = Session["loginUser"] as ERPUser; var list = bll.getOaIdById(erpUser.ID.ToString()); InfectionOpenUserInfoModel model = new InfectionOpenUserInfoBll().findById(int.Parse(id)); if (list.Count > 0) { string openid = new InfectionOpenUserBll().GetDataByID(model.user_id.ToString()).openid; object ob = bll.updateType(id, type, reason, pass_by, createTime.ToString()); string jsondata = Newtonsoft.Json.JsonConvert.SerializeObject(ob); JObject jo = (JObject)JsonConvert.DeserializeObject(jsondata); string su = jo["State"].ToString(); if (su.Equals("1")) { pass_by = erpUser.ID.ToString(); var data = new { touser = openid, template_id = "bbpoBaop3Qs5tYAjvokYDqr9bL2SQzp5g5mbGB-m0uo", url = "http://oa.dcqcdc.com/dccdc/Infection/personInfoEntering", data = new { first = new { value = "您好,您的信息已通过审核,请等待进行问卷调查!", color = "#173177" }, keyword1 = new { value = model.name, color = "#173177" }, keyword2 = new { value = model.ident, color = "#173177" }, keyword3 = new { value = model.phone, color = "#173177" }, remark = new { value = "您好,恭喜您已通过健康E路系统审核,请耐心等待进行问卷调查,我们已经为您准备好了丰厚的红包奖励和免费健康体检大礼包。", color = "#173177" }, } }; WebClient wc = new WebClient(); wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + Common.Global.getAccessTokenInfection.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data))); } if (su.Equals("2")) { var data = new { touser = openid, template_id = "XBUW_-9IUlj7KO3DJQ-pvcOipqCrWajQDZN3nw-61aI", url = "http://oa.dcqcdc.com/dccdc/Infection/personInfoEntering", data = new { first = new { value = "您好,您的申请未通过,请重新录入信息进行审核!", color = "#173177" }, keyword1 = new { value = createTime.ToString(), color = "#173177" }, keyword2 = new { value = "信息不完善", color = "#173177" }, //keyword3 = new { value = model.ADate.ToString("yyyy-MM-dd"), color = "#173177" }, remark = new { value = "对不起,您的信息未能通过健康E路系统审核,请核对好姓名、身份证件、驾驶证等信息后再次提交,谢谢。", color = "#173177" }, } }; WebClient wc = new WebClient(); wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + Common.Global.getAccessTokenInfection.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data))); } return Json(ob); } else { return Json("该用户未绑定,请先绑定"); } } public ActionResult addOpenUserInfoQuery() { List list = new InfectionOpenCrowdBll().GetOpenDataList(); List itemList = new List(); foreach (InfectionOpenCrowdModel crowd in list) { SelectListItem item = new SelectListItem() { Value = crowd.id.ToString(), Text = crowd.name.ToString() }; itemList.Add(item); } SelectList select = new SelectList(itemList, "Value", "Text"); ViewBag.crowdList = select; return View(); } public string addOpenUserInfoQuerySave(InfectionOpenUserInfoModel model) { InfectionOpenUserInfoBll bll = new InfectionOpenUserInfoBll(); if (Request.Files.Count == 0) { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "没有要处理的文件" }); } else { try { string path = string.Empty; string address = string.Empty; path = Server.MapPath("~/photo/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string specificDate = DateTime.Now.ToString("yyyyMMdd").ToString(); path += specificDate + "/"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } address = DateTime.Now.ToString("HHmmss") + "-" + Guid.NewGuid().ToString() + ".jpg"; path += address; Request.Files[0].SaveAs(path); address = "/photo/" + specificDate + "/" + address; model.license = address; DateTime date = new DateTime(); date = DateTime.Now; model.create_time = date.ToString("yyyy-MM-dd hh:mm:ss"); bll.Add(model); return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 1, Message = "保存成功!" }); } catch (Exception ex) { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = ex.Message }); } } //DateTime date = new DateTime(); //date = DateTime.Now; //model.create_time = date.ToString("yyyy-MM-dd hh:mm:ss"); //return Json(bll.Add(model)); } //导出excel public JsonResult downFile(string start, string end, string type, string status, bool flag = false) { if (string.IsNullOrEmpty(start) || string.IsNullOrEmpty(end)) return Json(null, JsonRequestBehavior.AllowGet); var bll = new ProfessionalExamRegisterBll(); var result = bll.getCl(start, end, type, status, flag); DataTable dt = new DataTable(); dt.Columns.Add("体检编号"); dt.Columns.Add("姓名"); dt.Columns.Add("企业"); dt.Columns.Add("登记日期"); dt.Columns.Add("联系电话"); foreach (var m in result) { DataRow mdr = dt.NewRow(); mdr["体检编号"] = m.physical_num; mdr["姓名"] = m.person_name; mdr["企业"] = m.util_name; mdr["登记日期"] = m.register_date; mdr["联系电话"] = m.phone; dt.Rows.Add(mdr); } string file = Guid.NewGuid().ToString("N") + ".xlsx"; string path = Server.MapPath("~/exp/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } try { xiaoy.Excel.ExcelFile.SetData(dt, path + file, xiaoy.Excel.ExcelVersion.Excel12, xiaoy.Excel.HDRType.Yes); return Json(new { State = "1", Message = file }); } catch (Exception ex) { return Json(new { State = "0", Message = ex.Message }); } } #endregion #region 微信页面 /// /// 根据openid获取userid /// /// /// [AllowAnonymous] public string GetUserIDByOpenID(string openid) { return new BLL.InfectionOpenUserBll().GetDataByOpenid(openid); } public string GetUserIDByOpenID2(string openid) { return new BLL.InfectionOpenUserBll().GetDataByOpenid2(openid); } [AllowAnonymous] public string GetOAuthOpenId(string code) { //log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("code:"+code); //log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("YMAppId:" + Common.Global.YMAppId); //log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("YMAppsecret:" + Common.Global.YMAppsecret); //return ""; string url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + Common.Global.InfectionAppId + "&secret=" + Common.Global.InfectionAppsecret + "&code=" + code + "&grant_type=authorization_code"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream stream = response.GetResponseStream(); //获取响应的字符串流 if (stream != null) { StreamReader sr = new StreamReader(stream); //创建一个stream读取流 string html = sr.ReadToEnd(); //从头读到尾,放到字符串html李米 sr.Close(); stream.Close(); log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(html); return html; } return ""; } [AllowAnonymous] public ActionResult inspectResult() { if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + "&response_type=code&scope=snsapi_base#wechat_redirect"); } string openidstr = GetOAuthOpenId(code); var openid = Newtonsoft.Json.JsonConvert.DeserializeObject(openidstr); string user_id = GetUserIDByOpenID(openid.openid); Session["InfectionUserID"] = user_id; HttpCookie hc = new HttpCookie("InfectionUserID"); hc.Value = user_id; Response.Cookies.Add(hc); } return View(); } [AllowAnonymous] public ActionResult inspectResultQuery() { if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + "&response_type=code&scope=snsapi_base#wechat_redirect"); } string openidstr = GetOAuthOpenId(code); var openid = Newtonsoft.Json.JsonConvert.DeserializeObject(openidstr); string user_id = GetUserIDByOpenID(openid.openid); Session["InfectionUserID"] = user_id; HttpCookie hc = new HttpCookie("InfectionUserID"); hc.Value = user_id; Response.Cookies.Add(hc); } fx(); return View(); } [AllowAnonymous] public ActionResult inspectResultQueryPC() { return View("inspectResultQuery"); } [AllowAnonymous] public ActionResult personInfo() { string userid = Request.QueryString["userid"]; string str = ""; //log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("userid============"+userid); if (!string.IsNullOrEmpty(userid)) { str = "?userid=" + userid; } //log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("str============" + str); if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + str + "&response_type=code&scope=snsapi_base#wechat_redirect"); } string openidstr = GetOAuthOpenId(code); var openid = Newtonsoft.Json.JsonConvert.DeserializeObject(openidstr); string user_id = GetUserIDByOpenID(openid.openid); Session["InfectionUserID"] = user_id; HttpCookie hc = new HttpCookie("InfectionUserID"); hc.Value = user_id; Response.Cookies.Add(hc); } ViewBag.userid = userid; return View(); } [AllowAnonymous] public ActionResult personInfoAudit() { if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + "&response_type=code&scope=snsapi_base#wechat_redirect"); } string openidstr = GetOAuthOpenId(code); var openid = Newtonsoft.Json.JsonConvert.DeserializeObject(openidstr); string user_id = GetUserIDByOpenID(openid.openid); Session["InfectionUserID"] = user_id; HttpCookie hc = new HttpCookie("InfectionUserID"); hc.Value = user_id; Response.Cookies.Add(hc); } return View(); } [AllowAnonymous] public ActionResult personInfoEntering() { string state = Request.QueryString["state"]; if (string.IsNullOrEmpty(state)) { state = "0"; } string remark = ""; if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + "&state=" + state + "&response_type=code&scope=snsapi_base#wechat_redirect"); } string openidstr = GetOAuthOpenId(code); var openid = Newtonsoft.Json.JsonConvert.DeserializeObject(openidstr); string user_id = GetUserIDByOpenID(openid.openid); remark = GetUserIDByOpenID2(openid.openid); Session["InfectionUserID"] = user_id; HttpCookie hc = new HttpCookie("InfectionUserID"); hc.Value = user_id; Response.Cookies.Add(hc); } else { var model = new BLL.InfectionOpenUserBll().GetDataByID(Session["InfectionUserID"].ToString()); remark = model.remark; } ViewBag.state = state; ViewBag.remark = remark; fx(); return View(); } [AllowAnonymous] public ActionResult personInfoEnteringPC() { return View("personInfoEntering"); } [AllowAnonymous] public ActionResult signIn() { if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + "&response_type=code&scope=snsapi_base#wechat_redirect"); } string openidstr = GetOAuthOpenId(code); var openid = Newtonsoft.Json.JsonConvert.DeserializeObject(openidstr); string user_id = GetUserIDByOpenID(openid.openid); Session["InfectionUserID"] = user_id; HttpCookie hc = new HttpCookie("InfectionUserID"); hc.Value = user_id; Response.Cookies.Add(hc); } fx(); return View(); } public ActionResult signIn2() { //if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") //{ // string code = Request.QueryString["code"]; // if (string.IsNullOrEmpty(code)) // { // return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + // "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + // "&response_type=code&scope=snsapi_base#wechat_redirect"); // } // string openidstr = GetOAuthOpenId(code); // var openid = Newtonsoft.Json.JsonConvert.DeserializeObject(openidstr); // string user_id = GetUserIDByOpenID(openid.openid); // Session["InfectionUserID"] = user_id; // HttpCookie hc = new HttpCookie("InfectionUserID"); // hc.Value = user_id; // Response.Cookies.Add(hc); //} return View(); } [AllowAnonymous] public ActionResult signInPC() { return View("signIn"); } [AllowAnonymous] public ActionResult subscribeEdit() { string id = Request.QueryString["id"]; string str = ""; if (!string.IsNullOrEmpty(id)) { str = "?id=" + id; } if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + "&response_type=code&scope=snsapi_base#wechat_redirect"); } string openidstr = GetOAuthOpenId(code); var openid = Newtonsoft.Json.JsonConvert.DeserializeObject(openidstr); string user_id = GetUserIDByOpenID(openid.openid); Session["InfectionUserID"] = user_id; HttpCookie hc = new HttpCookie("InfectionUserID"); hc.Value = user_id; Response.Cookies.Add(hc); } ViewBag.id = id; weixinBll wxBill = new weixinBll(); List jgList = wxBill.getyyjgs(); List itemList = new List(); foreach (tjjg info in jgList) { SelectListItem item = new SelectListItem() { Value = info.jgid.ToString(), Text = info.jgmc.ToString() }; itemList.Add(item); } SelectList select = new SelectList(itemList, "Value", "Text"); ViewBag.JGList = select; return View(); } [AllowAnonymous] public ActionResult subscribeInfo() { if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + "&response_type=code&scope=snsapi_base#wechat_redirect"); } string openidstr = GetOAuthOpenId(code); var openid = Newtonsoft.Json.JsonConvert.DeserializeObject(openidstr); string user_id = GetUserIDByOpenID(openid.openid); Session["InfectionUserID"] = user_id; HttpCookie hc = new HttpCookie("InfectionUserID"); hc.Value = user_id; Response.Cookies.Add(hc); } weixinBll wxBill = new weixinBll(); List jgList = wxBill.getyyjgs(); List itemList = new List(); foreach (tjjg info in jgList) { SelectListItem item = new SelectListItem() { Value = info.jgid.ToString(), Text = info.jgmc.ToString() }; itemList.Add(item); } SelectList select = new SelectList(itemList, "Value", "Text"); ViewBag.JGList = select; fx(); return View(); } [AllowAnonymous] public ActionResult userInfo() { if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + "&response_type=code&scope=snsapi_base#wechat_redirect"); } string openidstr = GetOAuthOpenId(code); var openid = Newtonsoft.Json.JsonConvert.DeserializeObject(openidstr); string user_id = GetUserIDByOpenID(openid.openid); Session["InfectionUserID"] = user_id; HttpCookie hc = new HttpCookie("InfectionUserID"); hc.Value = user_id; Response.Cookies.Add(hc); } fx(); return View(); } [AllowAnonymous] public ActionResult userInfoPC() { return View("userInfo"); } [AllowAnonymous] public ActionResult userSubscribe() { if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + "&response_type=code&scope=snsapi_base#wechat_redirect"); } string openidstr = GetOAuthOpenId(code); var openid = Newtonsoft.Json.JsonConvert.DeserializeObject(openidstr); string user_id = GetUserIDByOpenID(openid.openid); Session["InfectionUserID"] = user_id; HttpCookie hc = new HttpCookie("InfectionUserID"); hc.Value = user_id; Response.Cookies.Add(hc); } return View(); } [AllowAnonymous] public ActionResult relation() { if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + "&response_type=code&scope=snsapi_base#wechat_redirect"); } string openidstr = GetOAuthOpenId(code); var openid = Newtonsoft.Json.JsonConvert.DeserializeObject(openidstr); string user_id = GetUserIDByOpenID(openid.openid); Session["InfectionUserID"] = user_id; HttpCookie hc = new HttpCookie("InfectionUserID"); hc.Value = user_id; Response.Cookies.Add(hc); } fx(); return View(); } [AllowAnonymous] public ActionResult contact() { if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + "&response_type=code&scope=snsapi_base#wechat_redirect"); } } fx(); return View(); } [AllowAnonymous] public ActionResult repositorywx() { if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + "&response_type=code&scope=snsapi_base#wechat_redirect"); } string openidstr = GetOAuthOpenId(code); var openid = Newtonsoft.Json.JsonConvert.DeserializeObject(openidstr); string user_id = GetUserIDByOpenID(openid.openid); Session["InfectionUserID"] = user_id; HttpCookie hc = new HttpCookie("InfectionUserID"); hc.Value = user_id; Response.Cookies.Add(hc); } List models = new BLL.InfectionRepositoryBll().GetAllData(); fx(); return View(models); } [AllowAnonymous] public ActionResult repositoryInfowx() { if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + "&response_type=code&scope=snsapi_base#wechat_redirect"); } string openidstr = GetOAuthOpenId(code); var openid = Newtonsoft.Json.JsonConvert.DeserializeObject(openidstr); string user_id = GetUserIDByOpenID(openid.openid); Session["InfectionUserID"] = user_id; HttpCookie hc = new HttpCookie("InfectionUserID"); hc.Value = user_id; Response.Cookies.Add(hc); } string id = Request.QueryString["userid"]; var list = new BLL.InfectionRepositoryBll().GetDataByID(int.Parse(id)); if (list.Count > 0) { ViewBag.content = list[0].content; ViewBag.Title = list[0].title; ViewBag.create_time = list[0].create_time; } return View(); } [AllowAnonymous] public ActionResult PhysicalExaminationResult() { if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + "&response_type=code&scope=snsapi_base#wechat_redirect"); } string openidstr = GetOAuthOpenId(code); var openid = Newtonsoft.Json.JsonConvert.DeserializeObject(openidstr); string user_id = GetUserIDByOpenID(openid.openid); Session["InfectionUserID"] = user_id; HttpCookie hc = new HttpCookie("InfectionUserID"); hc.Value = user_id; Response.Cookies.Add(hc); } return View(); } #endregion #region 红包金额维护 // GET: ChargeRefund public ActionResult infectionRedMoney() { return View(); } public ActionResult InfectionRedMoneyAdd(string id) { infectionRedMoneyBll bll = new infectionRedMoneyBll(); infectionRedMoneyModel model = bll.getInitData(); return View(model); } public ActionResult Add(infectionRedMoneyModel model) { infectionRedMoneyBll bll = new infectionRedMoneyBll(); return Json(bll.Update(model)); } public ActionResult RedPacketRecord() { int monthOne = new InfectionRedBll().getMonthOne(); int monthTwo = new InfectionRedBll().getMonthTwo(); int allOne = new InfectionRedBll().getAllOne(); ViewBag.monthOne = monthOne; ViewBag.monthTwo = monthTwo; ViewBag.allOne = allOne; return View(); } /// /// 根据时间、类型分页获取数据 /// /// /// /// /// /// /// public JsonResult getRedPacketList(int page, int pagesize, string start, string end, string type, string status) { if (end != "" && end != null) { DateTime dateTime = Convert.ToDateTime(end); dateTime = dateTime.AddDays(1); end = dateTime.ToString("yyyy-MM-dd"); } List models = new BLL.InfectionRedBll().GetDataByTypeTime(page, pagesize, start, end, type, status); int count = new BLL.InfectionRedBll().GetDataCount(start, end, type, status); for (int i = 0; i < models.Count; i++) { if (models[i].status == 0) { models[i].redState = "发放中"; } else if (models[i].status == 1) { models[i].redState = "已发放待领取"; } else if (models[i].status == 2) { models[i].redState = "发放失败"; } else if (models[i].status == 3) { models[i].redState = "已提现"; } else if (models[i].status == 4) { models[i].redState = "退款中"; } else if (models[i].status == 5) { models[i].redState = "已退款"; } if (models[i].type == 1) { models[i].redType = "签到"; } else if (models[i].type == 2) { models[i].redType = "问卷调查"; } else if (models[i].type == 3) { models[i].redType = "体检"; } else if (models[i].type == 4) { models[i].redType = "推荐"; } } return Json(new { Total = count, Rows = models }); } #endregion #region 问卷调查 //添加页面 public ActionResult InformationAuditWJ(string id) { InfectionOpenUserInfoModel model = new InfectionOpenUserInfoModel(); model.id = Convert.ToInt32(id); return View(model); } //问卷列表 public ActionResult InformationWJ() { return View(); } public JsonResult getAllWJ() { BLL.InfectionQuestionAnswerBll bll = new BLL.InfectionQuestionAnswerBll(); List result = bll.GetAllDataList(); return Json(new { Rows = result }); } #endregion #region 知识库操作 public ActionResult Repository() { return View(); } /// /// 根据条件分页获取数据 /// /// /// /// /// /// /// public JsonResult getRepositoryList(int page, int pagesize, string title, string start, string end) { InfectionRepositoryBll bll = new BLL.InfectionRepositoryBll(); if (!string.IsNullOrEmpty(start)) { start += " 00:00:00"; } if (!string.IsNullOrEmpty(end)) { end += " 23:59:59"; } var result = bll.getAllDataList(page, pagesize, title, start, end); int count = bll.getCount(title, start, end); return Json(new { Total = count, Rows = result }); } public ActionResult RepositoryAdd() { return View(); } /// /// 保存数据 /// /// /// [HttpPost] [ValidateInput(false)] public JsonResult repositorySaveData(InfectionRepositoryModel model) { string address = string.Empty; if (Request.Files.Count != 0) { if (Request.Files[0].ContentLength > 0) { string s = Request.Files.GetType().ToString(); string path = string.Empty; try { path = Server.MapPath("~/repository/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string specificDate = DateTime.Now.ToString("yyyyMMdd").ToString(); path += specificDate + "/"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } address = DateTime.Now.ToString("HHmmss") + "-" + Guid.NewGuid().ToString() + ".jpg"; path += address; Request.Files[0].SaveAs(path); address = "/repository/" + specificDate + "/" + address; } catch { } } } model.address = address; model.create_time = DateTime.Now.ToString("yyyy-MM-dd HH:ss:mm"); return Json(new BLL.InfectionRepositoryBll().repositorySaveData(model)); } /// /// 根据ID查询数据 /// /// /// public ActionResult RepositoryModify(string id) { List models = new BLL.InfectionRepositoryBll().GetDataByID(int.Parse(id)); InfectionRepositoryModel model = new InfectionRepositoryModel(); if (models != null && models.Count > 0) { model = models[0]; ViewBag.src = "/dccdc" + model.address; ViewBag.content = model.content; } return View(model); } /// /// 根据ID修改数据,根据state判断是否修改图片地址 /// /// /// /// [HttpPost] [ValidateInput(false)] public JsonResult repositoryModifyData(InfectionRepositoryModel model, string state) { string address = string.Empty; if (state == "0") { if (Request.Files.Count != 0) { string s = Request.Files.GetType().ToString(); if (Request.Files[0].ContentLength > 0) { string path = string.Empty; try { path = Server.MapPath("~/photo/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string specificDate = DateTime.Now.ToString("yyyyMMdd").ToString(); path += specificDate + "/"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } address = DateTime.Now.ToString("HHmmss") + "-" + Guid.NewGuid().ToString() + ".jpg"; path += address; Request.Files[0].SaveAs(path); address = "/photo/" + specificDate + "/" + address; } catch { } } } } model.address = address; return Json(new BLL.InfectionRepositoryBll().repositoryModifyData(model, state)); } /// /// 根据ID查询数据 /// /// /// public ActionResult RepositoryDetails(string id) { List models = new BLL.InfectionRepositoryBll().GetDataByID(int.Parse(id)); InfectionRepositoryModel model = new InfectionRepositoryModel(); if (models != null && models.Count > 0) { model = models[0]; ViewBag.id = model.id; ViewBag.title = model.title; ViewBag.src = "/dccdc" + model.address; ViewBag.content = model.content; ViewBag.create_time = model.create_time; } return View(); } /// /// 根据id删除问题 /// /// /// public JsonResult deleteRepository(string id) { return Json(new BLL.InfectionRepositoryBll().deleteByID(id)); } [AllowAnonymous] public string xiaoLogin(string username, string pwd, string x, string y, string appName) { log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Info("username:" + username); log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Info("pwd:" + pwd); log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Info("x:" + x); log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Info("y:" + y); var m = new ERPUserBll().login(username, ""); if (m == null) { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "用户名密码错误!" }); } if (m.IfLogin != "是") { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "您的账号不能登记请联系管理员!" }); } if (ZWL.Common.DEncrypt.DESEncrypt.Decrypt(m.UserPwd) == pwd) { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 1, Message = "登录成功!" }); } else { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "用户名密码错误!" }); } } [AllowAnonymous] public JsonResult getCheckList() { //string user_id = Session["InfectionUserID"].ToString(); string user_id = "1"; var bll = new BLL.InfectionCheckBll(); //log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("user_id===================="+user_id); List checkList = bll.GetAllDataList(user_id); return Json(checkList); } [AllowAnonymous] public ActionResult userCheckIndex() { return View(); } [AllowAnonymous] public JsonResult userCheck(string answer, string questionId) { //int user_id = 1; log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Info("answer:" + answer); log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Info("questionId:" + questionId); int user_id; try { user_id = int.Parse(Session["InfectionUserID"].ToString()); } catch { return Json(new { State = 0, Message = "找不到个人信息!" }); } InfectionOpenUserModel openUser = new InfectionOpenUserBll().GetDataByID(user_id.ToString()); int infoCount = new InfectionOpenUserInfoBll().getDataCount(user_id); InfectionOpenUserInfoModel info = new InfectionOpenUserInfoModel(); if (infoCount > 0) { info = new InfectionOpenUserInfoBll().findByUserId(user_id); InfectionOpenCrowdModel crowd = new InfectionOpenCrowdBll().findById(int.Parse(info.crowd_id)); if (info == null) { return Json(new { State = 0, Message = "请先完成通过信息审核!" }); } else { if (crowd.isQuestion == 1) { if (openUser.state < 3) { return Json(new { State = 0, Message = "请先完成调查问卷!" }); } } else { if (openUser.state < 2) { return Json(new { State = 0, Message = "请先完成通过信息审核!" }); } } } } else { return Json(new { State = 0, Message = "请先完成信息录入!" }); } InfectionCheckModel model = new InfectionCheckModel(); model.user_id = user_id; //model.user_id = 1; model.state = 1; model.check_date = DateTime.Now.ToString("yyyy-MM-dd"); model.create_time = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); InfectionCheckBll bll = new InfectionCheckBll(); InfectionDaysignQuestionModel question = new InfectionDaysignQuestionBll().GetTodayQuestion(); InfectionDaysignQuestionAnswerModel answerModel = new InfectionDaysignQuestionAnswerModel(); answerModel.answer = answer; answerModel.info_id = info.id; answerModel.question_id = int.Parse(questionId); answerModel.create_by = user_id.ToString(); answerModel.create_time = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); new InfectionDaysignQuestionAnswerBll().SaveData(answerModel); return Json(bll.SaveData(model)); } #endregion internal Boolean SendWeiDaoTiJianTuiSong(InfectionOpenUserModel infectionOpenUserModel, InfectionOpenUserInfoModel openuserinfo, InfectionTestModel infectionTestModel) { try { string sex = ""; if (infectionOpenUserModel.sex == 1) { sex = "男"; } else if (infectionOpenUserModel.sex == 2) { sex = "女"; } string url = ""; if (infectionTestModel == null) { url = "http://oa.dcqcdc.com/dccdc/Infection/userSubscribe"; } else { url = "http://oa.dcqcdc.com/dccdc/Infection/subscribeEdit?id='" + infectionTestModel.id + "'"; } var data = new { touser = infectionOpenUserModel.openid, template_id = "ZnclBAlcBizkU-7NTIvyIqDeJy1Ym8AsavTUJNXoKz0", url = url, data = new { first = new { value = "你的体检预约已经逾期!请取消预约后,再次预约,谢谢!", color = "#173177" }, keyword1 = new { value = openuserinfo.name, color = "#173177" }, keyword2 = new { value = sex, color = "#173177" }, keyword3 = new { value = openuserinfo.phone, color = "#173177" }, keyword4 = new { value = "健康大礼包", color = "#173177" }, keyword5 = new { value = infectionTestModel.order_date, color = "#173177" }, remark = new { value = "点击查看预约详情", color = "#173177" }, } }; WebClient wc = new WebClient(); var result = wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + Common.Global.getAccessTokenInfection.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data))); string jg = System.Text.Encoding.UTF8.GetString(result); var rjg = Newtonsoft.Json.JsonConvert.DeserializeObject(jg); log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("rjg.errmsg:" + rjg.errmsg); if (rjg.errmsg == "ok") { log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(rjg.errmsg); return true; } else { log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(rjg.errmsg); return false; } } catch (Exception ex) { return false; } } public string sendTestFinish(int ma_id) { string return_value = ""; try { InfectionTestModel test = new InfectionTestBll().getDataByMaId(ma_id); InfectionOpenUserInfoModel openuserinfo = new InfectionOpenUserInfoBll().findById(test.info_id); InfectionOpenUserModel openuser = new InfectionOpenUserBll().GetDataByID(openuserinfo.user_id.ToString()); string sex = ""; if (openuser.sex == 1) { sex = "男"; } else if (openuser.sex == 2) { sex = "女"; } var data = new { touser = openuser.openid, template_id = "ZnclBAlcBizkU-7NTIvyIqDeJy1Ym8AsavTUJNXoKz0", //url = "http://oa.dcqcdc.com/dccdc/Infection/userSubscribe", data = new { first = new { value = "你的预约体检已完成", color = "#173177" }, keyword1 = new { value = openuserinfo.name, color = "#173177" }, keyword2 = new { value = sex, color = "#173177" }, keyword3 = new { value = test.phone, color = "#173177" }, keyword4 = new { value = "健康大礼包", color = "#173177" }, keyword5 = new { value = test.order_date, color = "#173177" }, remark = new { value = "恭喜您,在您的帮助下,您的健康档案已经初步建立,请耐心等待体检结果,我们将在第一时间通知您。", color = "#173177" }, } }; WebClient wc = new WebClient(); wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + Common.Global.getAccessTokenInfection.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data))); return_value = "发送成功"; return return_value; } catch (Exception ex) { return ex.Message; } } public string sendTestReport(int ma_id) { string return_value = ""; try { InfectionTestModel test = new InfectionTestBll().getDataByMaId(ma_id); InfectionOpenUserInfoModel openuserinfo = new InfectionOpenUserInfoBll().findById(test.info_id); InfectionOpenUserModel openuser = new InfectionOpenUserBll().GetDataByID(openuserinfo.user_id.ToString()); string sex = ""; if (openuser.sex == 1) { sex = "男"; } else if (openuser.sex == 2) { sex = "女"; } var data = new { touser = openuser.openid, template_id = "ZnclBAlcBizkU-7NTIvyIqDeJy1Ym8AsavTUJNXoKz0", //url = "http://oa.dcqcdc.com/dccdc/Infection/userSubscribe", data = new { first = new { value = "你的预约体检已完成", color = "#173177" }, keyword1 = new { value = openuserinfo.name, color = "#173177" }, keyword2 = new { value = sex, color = "#173177" }, keyword3 = new { value = test.phone, color = "#173177" }, keyword4 = new { value = "健康大礼包", color = "#173177" }, keyword5 = new { value = test.order_date, color = "#173177" }, remark = new { value = "恭喜您,您的健康档案已经建立!请点击公众号右下角“健康加油站”查询档案内容。请继续关注本公众号,我们将持续为您提供健康资讯,跟随我们,您将获得更多更全面的防病治病知识。", color = "#173177" }, } }; WebClient wc = new WebClient(); wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + Common.Global.getAccessTokenInfection.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data))); return_value = "发送成功"; return return_value; } catch (Exception ex) { return ex.Message; } } //健康大礼包 [AllowAnonymous] public ActionResult Package() { return View(); } //关注页面 [AllowAnonymous] public ActionResult Follow() { return View(); } [AllowAnonymous] public void getMaterial() { var data = new { type = "image", offset = "0", count = "20" }; WebClient wc = new WebClient(); log4net.LogManager.GetLogger(this.GetType()).Info(Newtonsoft.Json.JsonConvert.SerializeObject(data)); wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); var result = wc.UploadData("https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=" + Common.Global.getAccessTokenInfection.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data))); string jg = System.Text.Encoding.UTF8.GetString(result); log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("material====================" + jg); } #region 科目维护(艾滋问答) public ActionResult kemuquestion() { return View(); } public string kemuquestionAll() { var dal = new kemuquestionBll(); string modelslistjson = JsonConvert.SerializeObject(dal.GetAllList("")); return "{\"Rows\":" + modelslistjson + "}"; } public ActionResult kemuquestionMessage(string id) { var list = new List() { new Droplist { Value = "1", Title = "正常" }, new Droplist { Value = "2", Title = "禁用" } }; var bll = new kemuquestionBll(); if (!string.IsNullOrEmpty(id)) { var model = bll.GetAllList(id).First(); ViewData["ztD"] = new SelectList(list, "value", "title", model.zt); return View(model); } else { ViewData["ztD"] = new SelectList(list, "value", "title", "1"); return View(); } } [HttpPost] public ActionResult kemuquestionMessage(kemuquestionModel model) { ModelState.Remove("id"); if (!ModelState.IsValid) { var list = new List() { new Droplist { Value = "1", Title = "正常" }, new Droplist { Value = "2", Title = "禁用" } }; ViewData["ztD"] = new SelectList(list, "value", "title"); return View(model); } kemuquestionBll bll = new kemuquestionBll(); model.addtime = DateTime.Now; //修改 var f = false; f = model.id != 0 ? bll.Update(model) : bll.Add(model); return Json(f ? new { State = 1, Message = "操作成功!" } : new { State = 0, Message = "操作失败!" }); } public JsonResult deletekemuquestion(string id) { if (string.IsNullOrEmpty(id)) return Json(null); return Json(new BLL.kemuquestionBll().delete(id)); } public JsonResult kemuquestionRandom() { var dal = new kemuquestionBll(); var models = dal.GetAllList(""); JsonResult result = Json(new { Question = models }, JsonRequestBehavior.AllowGet); return result; } #endregion [AllowAnonymous] public string testCheck() { BkyyrqBll bkyyrqbll = new BkyyrqBll(); int dayCheck = bkyyrqbll.checkDate("2018-05-01"); if (dayCheck == 1) { return "非工作日无法预约体检!"; } else { return ""; } } [AllowAnonymous] public string testDate() { DateTime d1 = new DateTime(2012, 1, 1, 15, 36, 05); DateTime d2 = new DateTime(2012, 2, 1, 20, 16, 35); TimeSpan d3 = d2.Subtract(d1); return d3.Days.ToString(); } #region 推荐分享 [AllowAnonymous] public ActionResult tjfx() { if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + "&response_type=code&scope=snsapi_base#wechat_redirect"); } } fx(); return View(); } [AllowAnonymous] public ActionResult tjfx2(string recommend, string id, string name) { ViewBag.name = name; ViewBag.recommend = recommend; ViewBag.url = Common.Global.qrcode_ticketInfection(recommend); return View(); } [AllowAnonymous] public ActionResult tjfxcount() { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.InfectionAppId + "&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) + "&response_type=code&scope=snsapi_base#wechat_redirect"); } string openidstr = GetOAuthOpenId(code); var openid = Newtonsoft.Json.JsonConvert.DeserializeObject(openidstr); string user_id = GetUserIDByOpenID(openid.openid); var model = new BLL.InfectionOpenUserInfoBll().GetDataListByUserID(Convert.ToInt32(user_id)); var list = new BLL.InfectionOpenUserInfoBll().GetDataListByReferee(model[0].referee); int count1 = list.Count; int count2 = 0; if (count1 > 0) { string ids = "0"; foreach (InfectionOpenUserInfoModel m in list) { ids += "," + m.id; } var bll = new InfectionTestBll(); count2 = bll.getCountids(ids); } ViewBag.count1 = count1; ViewBag.count2 = count2; fx(); return View(); } #endregion //公共函数 private void fx() { if (Session["InfectionUserID"] == null || Session["InfectionUserID"].ToString() == "") { string code = Request.QueryString["code"]; string openidstr = GetOAuthOpenId(code); var openid = Newtonsoft.Json.JsonConvert.DeserializeObject(openidstr); string user_id = GetUserIDByOpenID(openid.openid); Session["InfectionUserID"] = user_id; HttpCookie hc = new HttpCookie("InfectionUserID"); hc.Value = user_id; Response.Cookies.Add(hc); var model = new BLL.InfectionOpenUserInfoBll().GetDataListByUserID(Convert.ToInt32(user_id)); if (model.Count == 0) { //return Redirect("personInfoEntering"); var modelUser = new InfectionOpenUserBll().GetDataByID(user_id); ViewBag.id = ""; ViewBag.name = modelUser.nickname; ViewBag.recommend = modelUser.recommendold; ViewBag.license = modelUser.headimgurl; } else { ViewBag.id = model[0].id; ViewBag.name = model[0].name; ViewBag.recommend = model[0].recommend; ViewBag.license = "http://oa.dcqcdc.com/dccdc/" + model[0].license; } } else { var model = new BLL.InfectionOpenUserInfoBll().GetDataListByUserID(Convert.ToInt32(Session["InfectionUserID"])); if (model.Count == 0) { //return Redirect("personInfoEntering"); var modelUser = new InfectionOpenUserBll().GetDataByID(Session["InfectionUserID"].ToString()); ViewBag.id = ""; ViewBag.name = modelUser.nickname; ViewBag.recommend = modelUser.recommendold; ViewBag.license = modelUser.headimgurl; } else { ViewBag.id = model[0].id; ViewBag.name = model[0].name; ViewBag.recommend = model[0].recommend; ViewBag.license = "http://oa.dcqcdc.com/dccdc/" + model[0].license; } } ViewBag.timeStamp = WxPayAPI.WxPayApi.GenerateTimeStamp(); ViewBag.nonceStr = Guid.NewGuid().ToString("N"); string[] ArrayList = { "jsapi_ticket=" + Common.Global.jsapi_ticketInfection, "timestamp=" + ViewBag.timeStamp, "noncestr=" + ViewBag.nonceStr, "url=" + Request.Url.AbsoluteUri.Split('#')[0] }; Array.Sort(ArrayList); string signature = string.Join("&", ArrayList); var sha1 = System.Security.Cryptography.SHA1.Create(); signature = BitConverter.ToString(sha1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(signature))).Replace("-", ""); //对该字符串进行sha1加密 signature = signature.ToLower();//对字符串中的字母部分进行小写转换,非字母字符不作处理 ViewBag.signature = signature; } } }