using Aliyun.Acs.Core; using Aliyun.Acs.Core.Exceptions; using Aliyun.Acs.Core.Profile; using Aliyun.Acs.Dysmsapi.Model.V20170525; using dccdc.BLL; using dccdc.Common; using dccdc.Models; using System; using System.Collections.Generic; using System.Configuration; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Linq; using System.Net; using System.Reflection; using System.Security.Cryptography; using System.Text; using System.Web; using System.Web.Mvc; namespace dccdc.Controllers { public class wxappController : Controller { // GET: wxapp //appName:小程序名称 [AllowAnonymous] public string login(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); log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Info("appName:" + appName); 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 string login2(string yhid) { var m = new ERPUserBll().login2(yhid); if (m == null) { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "无此用户id!" }); } return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 1, Message = "登录成功!" }); } #region 预约查询 [AllowAnonymous] public string getyyList(string key, string yyrq) { var bll = new MedicalAppointmentBll(); //var list = bll.getYYList(key, yyrq, "0", 1, 1000, Common.Global.jgid, 0); Common.Global.jgid 内部session 不能使用 var list = bll.getYYList(key, yyrq, "0", 1, 1000, 49, 0); return Newtonsoft.Json.JsonConvert.SerializeObject(list); } [AllowAnonymous] public string getyyrs() { var mab = new MedicalAppointmentBll(); var yyrs = mab.getYYRS(); return Newtonsoft.Json.JsonConvert.SerializeObject(yyrs); } #endregion #region 快速办证 //获取快速办证 [AllowAnonymous] public string getksbzList(string key) { if (string.IsNullOrEmpty(key)) { //var list = new BLL.ProfessionalExamRegisterBll().getKSBZList("", "", DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("yyyy-MM-dd"), "", ""); var list = new BLL.ProfessionalExamRegisterBll().getKSBZList("", "", "", "", "", ""); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = list.Count, Rows = list }); } else { long number; List list; if (long.TryParse(key, out number)) { list = new BLL.ProfessionalExamRegisterBll().getKSBZList(key, "", "", "", "", ""); } else { list = new BLL.ProfessionalExamRegisterBll().getKSBZList("", key, "", "", "", ""); } return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = list.Count, Rows = list }); } } [AllowAnonymous] //获取快速办证 测试用 public string getksbzList2(string key) { if (string.IsNullOrEmpty(key)) { var list = new BLL.ProfessionalExamRegisterBll().getKSBZList("", "", DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("yyyy-MM-dd"), "1", ""); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = list.Count, Rows = list }); } else { long number; List list; if (long.TryParse(key, out number)) { list = new BLL.ProfessionalExamRegisterBll().getKSBZList(key, "", "", "", "1", ""); } else { list = new BLL.ProfessionalExamRegisterBll().getKSBZList("", key, "", "", "1", ""); } return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = list.Count, Rows = list }); } } [AllowAnonymous] // 快速办证ajax请求页面 public string ksbz(string ids) { if (string.IsNullOrEmpty(ids)) { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 1, Message = "没有要快速出证的人员!" }); } if (ids.EndsWith(",")) { ids = ids.TrimEnd(','); } ids = ids.TrimStart(','); var bll = new ProfessionalExamRegisterBll(); //var or = bll.ksbz(ids, Common.Global.jgid); jgid没有使用 var or = bll.ksbz(ids, 0); return Newtonsoft.Json.JsonConvert.SerializeObject(or); } #endregion #region 疫苗减免 [AllowAnonymous] /// sv /// 获取减免申请列表 /// /// public string GetJmsqList(string key, string all, string username) { //审核中 string lx = "0"; string xm = key; string sqsjb = ""; string sqsje = ""; //if (string.IsNullOrEmpty(xm)) //{ // sqsjb = DateTime.Now.ToString("yyyy-MM-dd"); // sqsje = DateTime.Now.ToString("yyyy-MM-dd"); //} //DateTime dte; //if (DateTime.TryParse(sqsje, out dte)) //{ // sqsje = (dte.AddDays(1)).ToString("yyyy-MM-dd"); //} JmsqBll bll = new JmsqBll(); //此处参数配置根据管理员可查询不同减免类型数据先写死 BLL.Common combll = new BLL.Common(); string jffjid = combll.getParm_Value("jmfjid", "1", "可减免附件项的用户ID"); string jfqbid = combll.getParm_Value("jmqbid", "1", "可减免全部项的用户ID"); if (all == "true") { return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = bll.GetJmsqList(lx, "-1", xm, sqsjb, sqsje) }); } //var user = Session["loginUser"] as Models.ERPUser; //此处不能使用session var user = new ERPUserBll().login(username, ""); if (user.ID.ToString() == jfqbid) { string jmlx = "-1"; return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = bll.GetJmsqList(lx, jmlx, xm, sqsjb, sqsje) }); } else if (user.ID.ToString() == jffjid) { string jmlx = "0"; return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = bll.GetJmsqList(lx, jmlx, xm, sqsjb, sqsje) }); } else { return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = new List() }); } } [AllowAnonymous] public string GetJmsqListbyuser(string key, string username) { JmsqBll bll = new JmsqBll(); var user = new ERPUserBll().login(username, ""); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = bll.GetJmsqList2(key, user.ID.ToString()) }); } private int GetJmsqList2(string key, string all, string username) { //审核中 string lx = "0"; string xm = key; string sqsjb = ""; string sqsje = ""; //if (string.IsNullOrEmpty(xm)) //{ // sqsjb = DateTime.Now.ToString("yyyy-MM-dd"); // sqsje = DateTime.Now.ToString("yyyy-MM-dd"); //} //DateTime dte; //if (DateTime.TryParse(sqsje, out dte)) //{ // sqsje = (dte.AddDays(1)).ToString("yyyy-MM-dd"); //} JmsqBll bll = new JmsqBll(); //此处参数配置根据管理员可查询不同减免类型数据先写死 BLL.Common combll = new BLL.Common(); string jffjid = combll.getParm_Value("jmfjid", "1", "可减免附件项的用户ID"); string jfqbid = combll.getParm_Value("jmqbid", "1", "可减免全部项的用户ID"); if (all == "true") { return bll.GetJmsqList(lx, "-1", xm, sqsjb, sqsje).Count; } //var user = Session["loginUser"] as Models.ERPUser; //此处不能使用session var user = new ERPUserBll().login(username, ""); if (user.ID.ToString() == jfqbid) { string jmlx = "-1"; return bll.GetJmsqList(lx, jmlx, xm, sqsjb, sqsje).Count; } else if (user.ID.ToString() == jffjid) { string jmlx = "0"; return bll.GetJmsqList(lx, jmlx, xm, sqsjb, sqsje).Count; } else { return 0; } } [AllowAnonymous] public string GetJmmxList(string jmsqid) { JmmxBll bll = new JmmxBll(); List models = bll.GetJmmxList(jmsqid); List vmmodels = new List(); ChargeProjectMaintainBll bll1 = new ChargeProjectMaintainBll(); List sfxmal = bll1.GetAllList("", "是"); foreach (var m in models) { JmmxVModel m1 = new JmmxVModel { sfxm = sfxmal.First(i => i.id.ToString() == m.sfxmid).charge_project_name, jmdj = Convert.ToDouble(m.jmdj), sfxmid = Convert.ToInt32(m.sfxmid), jmsl = m.jmsl }; vmmodels.Add(m1); } return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = vmmodels }); } [AllowAnonymous] public string UpdateJmsqLxs(string jmsqids, string lx, string username) { foreach (string jmsqid in jmsqids.Split(',')) { UpdateJmsqLx(jmsqid, lx, username); } return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 1, Message = "操作成功!" }); } [AllowAnonymous] public string UpdateJmsqLx(string jmsqid, string lx, string username) { JmsqBll bll = new JmsqBll(); //var erpUser = Session["loginUser"] as Models.ERPUser; //此处不能使用session var erpUser = new ERPUserBll().login(username, ""); Models.DTO.ymshjg f = bll.UpdateJmsq(jmsqid, lx, erpUser); if (f.jz != "") { var commonbll = new BLL.Common(); string yddx = commonbll.getParm_Value("qyyddx", "false", "是否启用移动短信"); f.sp = erpUser.TrueName; 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("aldxtzmb", "SMS_91930060", "短信模版"); //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 = commonbll.getParm_Value("ymjmdxtz", "18653582965", "疫苗减免通知手机"); //必填:短信签名-可在短信控制台中找到 request.SignName = qm; //必填:短信模板-可在短信控制台中找到 request.TemplateCode = dxmb; //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为 request.TemplateParam = Newtonsoft.Json.JsonConvert.SerializeObject(f); //可选: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}); } } 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 = commonbll.getParm_Value("ymjmdxtz", "18653582965", "疫苗减免通知手机"); req.sign = commonbll.getParm_Value("yddxsign", "d37CYmrbG", "签名编码"); //req.content = "由" + f.sp + "审批的疫苗缴费减免已生效;接种者" + f.jz + "应缴费" + f.yj + "实际缴费" + f.sj; req.templateId = "44b9ed56aebc4b8fb4014f7c4c0ff00d"; req.addSerial = ""; string[] parms = new string[4]; parms[0] = f.sp; parms[1] = f.jz; parms[2] = f.yj; parms[3] = f.sj; 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"); log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(upstr); //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 Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 1, Message = "操作成功!" }); } [AllowAnonymous] public String init() { var chargebll = new chargeBll(); var sftj = chargebll.getSFTJ(); var proExamRBll = new ProfessionalExamRegisterBll(); var jkzdy = proExamRBll.getJKZDY(); var mab = new MedicalAppointmentBll(); var yyrs = mab.getYYRS(); var yylx = mab.getYYLX(); var monthjf = chargebll.getmonthjf(); var ymdjbll = new YMDJBll(); var ymdj = ymdjbll.getymdj(); return Newtonsoft.Json.JsonConvert.SerializeObject(new { sftj = sftj, jkzdy = jkzdy, yyrs = yyrs, yylx = yylx, monthjf = monthjf, ymdj = ymdj }); } #endregion #region 经费申请 [AllowAnonymous] // 获取经费申请列表 public string getsqjf(string key, string id, string username) { string where; if (!string.IsNullOrEmpty(id)) { where = " id=" + id; } else { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; List zws = getZW(user); //非职务人员 if (zws.Count == 0) return Newtonsoft.Json.JsonConvert.SerializeObject(null); where = "(1=2"; foreach (string zw in zws) { switch (zw) { case "1": where += " or (zt=1 and exists (select 1 from oa..erpbumen where id=ksid and chargeMan='" + user.UserName + "'))"; break; case "2": where += " or (zt=2 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; case "7": where += " or (zt=7 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; } } where += ") and del != 1"; if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } } var bll = new BLL.xmjfsysqBll(); int count = bll.getCountLevel(where); var models = bll.getPageLevel(1, 1000, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } [AllowAnonymous] // 获取经费申请明细 public string getsqjfmx(string key, string key1, string id) { var bllmx = new BLL.xmjfsysqmxBll(); var modelmx = bllmx.GetListByParent(id); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = modelmx }); } [AllowAnonymous] // 经费申请保存 public string savesqjf(string id, string yj, string ty, string username) { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; var bll = new BLL.xmjfsysqBll(); var model2 = bll.GetAllList(id).First(); string zwone = getZWOne(model2.zt.ToString(), user); if (zwone == "未知") { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "未知职位" }); } var model = new sqshModel(); model.type = "经费申请"; model.sqid = Convert.ToInt32(id); model.spr = user.TrueName; model.sptime = DateTime.Now; model.spnr = yj; model.zt = (ty == "1") ? "通过" : "不通过"; model.spzw = zwone; new BLL.sqshBll().Add(model); //微信消息通知 wxxx(model2.id, model2.sqrid, model2.ksmc, model2.sqr, model2.bz, model, user.UserName); return Newtonsoft.Json.JsonConvert.SerializeObject(bll.opSp(id, user.ID, user.TrueName, yj, (ty == "1") ? true : false)); } #endregion #region 三重一大审批 [AllowAnonymous] // 获取三重一大申请列表 public string getsqszyd(string key, string id, string username) { string where; if (!string.IsNullOrEmpty(id)) { where = " id=" + id; } else { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; List zws = getZW(user); //非职务人员 if (zws.Count == 0) return Newtonsoft.Json.JsonConvert.SerializeObject(null); where = "(1=2 "; foreach (string zw in zws) { switch (zw) { case "1": where += " or (zt=1 and exists (select 1 from oa..erpbumen where id=ksid and chargeMan='" + user.UserName + "'))"; break; case "2": where += " or (zt=2 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; case "3": where += " or (zt=3)"; break; //内审 会签 备案 全部科室 case "4": where += " or (zt=4)"; break; case "5": where += " or (zt=5)"; break; case "7": where += " or (zt=7 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; } } where += ") and del != 1"; if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } } var bll = new BLL.szyd_zjsysqBll(); int count = bll.getCountLevel(where); var models = bll.getPageLevel(1, 1000, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } [AllowAnonymous] public string getsqszydmx(string key, string key1, string id) { var bll = new BLL.szyd_zjsysqBll(); var models = bll.GetAllList(id); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = models }); } [AllowAnonymous] public string savesqszyd(string id, string yj, string ty, string username) { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; var bll = new BLL.szyd_zjsysqBll(); var model2 = bll.GetAllList(id).First(); string zwone = getZWOne(model2.zt.ToString(), user); if (zwone == "未知") { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "未知职位" }); } var model = new sqshModel(); model.type = "三重一大申请"; //添加 查询与添加一致就行 model.sqid = Convert.ToInt32(id); model.spr = user.TrueName; model.sptime = DateTime.Now; model.spnr = yj; model.zt = (ty == "1") ? "通过" : "不通过"; model.spzw = zwone; new BLL.sqshBll().Add(model); //微信消息通知 wxxx(model2.id, model2.sqrid, model2.ksmc, model2.sqr, model2.nr, model, user.UserName); return Newtonsoft.Json.JsonConvert.SerializeObject(bll.opSzydSp(id, user.ID, user.TrueName, yj, (ty == "1") ? true : false)); } #endregion #region 费用支出 [AllowAnonymous] // 获取经费申请列表 public string getsqfyzc(string key, string id, string username) { string where; if (!string.IsNullOrEmpty(id)) { where = " id=" + id; } else { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; List zws = getZW(user); //非职务人员 if (zws.Count == 0) return Newtonsoft.Json.JsonConvert.SerializeObject(null); where = "(1=2 "; foreach (string zw in zws) { switch (zw) { case "1": where += " or (zt=1 and exists (select 1 from oa..erpbumen where id=ksid and chargeMan='" + user.UserName + "'))"; break; case "2": where += " or (zt=2 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; case "3": where += " or (zt=3)"; break; //内审 会签 备案 财务 全部科室 case "4": where += " or (zt=4)"; break; case "5": where += " or (zt=5)"; break; case "6": where += " or (zt=6)"; break; case "7": where += " or (zt=7 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; } } where += ")"; if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } } var bll = new BLL.sqfyzcBll(); int count = bll.getCountLevel(where); var models = bll.getPageLevel(1, 1000, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } [AllowAnonymous] // 获取经费申请明细 public string getsqfyzcmx(string key, string key1, string id) { var bllmx = new BLL.sqfyzcmxBll(); var modelmx = bllmx.GetListByParent(id); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = modelmx }); } [AllowAnonymous] // 经费申请保存 public string savesqfyzc(string id, string yj, string ty, string username) { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; var bll = new BLL.sqfyzcBll(); var model2 = bll.GetAllList(id).First(); string zwone = getZWOne(model2.zt.ToString(), user); if (zwone == "未知") { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "未知职位" }); } var model = new sqshModel(); model.type = "费用支出申请"; model.sqid = Convert.ToInt32(id); model.spr = user.TrueName; model.sptime = DateTime.Now; model.spnr = yj; model.zt = (ty == "1") ? "通过" : "不通过"; model.spzw = zwone; new BLL.sqshBll().Add(model); //if (!string.IsNullOrEmpty(model2.fydh)) //{ // model.type = "经费申请"; // model.sqid = Convert.ToInt32(model2.fydh); // new BLL.sqshBll().Add(model); //} //if (!string.IsNullOrEmpty(model2.fydh2)) //{ // model.type = "三重一大申请"; // model.sqid = Convert.ToInt32(model2.fydh2); // new BLL.sqshBll().Add(model); //} //if (!string.IsNullOrEmpty(model2.dydh)) //{ // model.type = "物资采购"; // model.sqid = Convert.ToInt32(model2.dydh); // new BLL.sqshBll().Add(model); //} //if (!string.IsNullOrEmpty(model2.dydh2)) //{ // model.type = "维修"; // model.sqid = Convert.ToInt32(model2.dydh2); // new BLL.sqshBll().Add(model); //} //if (!string.IsNullOrEmpty(model2.dydh3)) //{ // model.type = "加班用餐"; // model.sqid = Convert.ToInt32(model2.dydh3); // new BLL.sqshBll().Add(model); //} //if (!string.IsNullOrEmpty(model2.dydh4)) //{ // model.type = "公务接待"; // model.sqid = Convert.ToInt32(model2.dydh4); // new BLL.sqshBll().Add(model); //} //微信消息通知 wxxx(model2.id, model2.sqrid, model2.ksmc, model2.sqr, model2.bz, model, user.UserName); return Newtonsoft.Json.JsonConvert.SerializeObject(bll.opSp(id, user.ID, user.TrueName, yj, (ty == "1") ? true : false)); } #endregion #region 预算申请 [AllowAnonymous] // 获取预算申请列表 public string getsqys(string key, string id, string username) { string where; if (!string.IsNullOrEmpty(id)) { where = " id=" + id; } else { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; List zws = getZW(user); //非职务人员 if (zws.Count == 0) return Newtonsoft.Json.JsonConvert.SerializeObject(null); where = "(1=2"; foreach (string zw in zws) { switch (zw) { case "1": where += " or (zt=1 and exists (select 1 from oa..erpbumen where id=ksid and chargeMan='" + user.UserName + "'))"; break; case "2": where += " or (zt=2 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; case "6": where += " or (zt=6)"; break; case "7": where += " or (zt=7 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; } } where += ")"; if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } } var bll = new BLL.sqysBll(); int count = bll.getCountLevel(where); var models = bll.getPageLevel(1, 1000, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } [AllowAnonymous] // 获取预算申请明细 public string getsqysmx(string key, string key1, string id) { var bllmx = new BLL.sqysmxBll(); var modelmx = bllmx.GetListByParent(id); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = modelmx }); } [AllowAnonymous] // 预算申请保存 public string savesqys(string id, string yj, string ty, string username, string spjea, string spjeb) { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; var bll = new BLL.sqysBll(); var model2 = bll.GetAllList(id).First(); string zwone = getZWOne(model2.zt.ToString(), user); if (zwone == "未知") { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "未知职位" }); } var model = new sqshModel(); model.type = "预算申请"; //添加 查询与添加一致就行 model.sqid = Convert.ToInt32(id); model.spr = user.TrueName; model.sptime = DateTime.Now; model.spnr = yj; model.zt = (ty == "1") ? "通过" : "不通过"; model.spzw = zwone; new BLL.sqshBll().Add(model); //微信消息通知 wxxx(model2.id, model2.sqrid, model2.ksmc, model2.sqr, model2.bz, model, user.UserName); return Newtonsoft.Json.JsonConvert.SerializeObject(bll.opSp(id, user.ID, user.TrueName, yj, (ty == "1") ? true : false, spjea, spjeb)); } #endregion #region 出差审批 [AllowAnonymous] public string getsqcc(string key, string id, string username) { string where; if (!string.IsNullOrEmpty(id)) { where = " id=" + id; } else { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; List zws = getZW(user); //非职务人员 if (zws.Count == 0) return Newtonsoft.Json.JsonConvert.SerializeObject(null); where = "(1=2"; foreach (string zw in zws) { switch (zw) { case "1": where += " or (zt=1 and exists (select 1 from oa..erpbumen where id=ksid and chargeMan='" + user.UserName + "'))"; break; case "2": where += " or (zt=2 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; case "3": where += " or (zt=3)"; break; //内审 会签 备案 全部科室 case "4": where += " or (zt=4)"; break; case "5": where += " or (zt=5)"; break; case "7": where += " or (zt=7 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; } } where += ")"; if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } } var bll = new BLL.chuchai_sqBll(); int count = bll.getCountLevel(where); var models = bll.getPageLevel(1, 1000, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } [AllowAnonymous] public string getsqccmx(string key, string key1, string id) { var bllmx = new BLL.chuchai_sqBll(); var modelmx = bllmx.GetAllList(id); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = modelmx }); } [AllowAnonymous] public string savesqcc(string id, string username, string yj, string ty) { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; var bll = new BLL.chuchai_sqBll(); var model2 = bll.GetAllList(id).First(); string zwone = getZWOne(model2.zt.ToString(), user); if (zwone == "未知") { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "未知职位" }); } var model = new sqshModel(); model.type = "出差审批"; //添加 查询与添加一致就行 model.sqid = Convert.ToInt32(id); model.spr = user.TrueName; model.sptime = DateTime.Now; model.spnr = yj; model.zt = (ty == "1") ? "通过" : "不通过"; model.spzw = zwone; new BLL.sqshBll().Add(model); //微信消息通知 wxxx(model2.id, model2.sqrid, model2.ksmc, model2.sqr, model2.sy, model, user.UserName); return Newtonsoft.Json.JsonConvert.SerializeObject(bll.opCcSp(id, user.ID, user.TrueName, yj, (ty == "1") ? true : false)); } #endregion #region 出差报销审批 [AllowAnonymous] public string getsqccbx(string key, string id, string username) { string where; if (!string.IsNullOrEmpty(id)) { where = " id=" + id; } else { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; List zws = getZW(user); //非职务人员 if (zws.Count == 0) return Newtonsoft.Json.JsonConvert.SerializeObject(null); where = "(1=2"; foreach (string zw in zws) { switch (zw) { case "1": where += " or (zt=1 and exists (select 1 from oa..erpbumen where id=ksid and chargeMan='" + user.UserName + "'))"; break; case "2": where += " or (zt=2 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; case "6": where += " or (zt=6)"; break; case "7": where += " or (zt=7 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; } } where += ")"; if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } } var bll = new BLL.sqccbxBll(); int count = bll.getCountLevel(where); var models = bll.getPageLevel(1, 1000, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } [AllowAnonymous] public string getsqccbxmx(string key, string key1, string id) { var bllmx = new BLL.sqccbxmxBll(); var modelmx = bllmx.GetListByParent(id); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = modelmx }); } [AllowAnonymous] public string savesqccbx(string id, string username, string yj, string ty) { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; var bll = new BLL.sqccbxBll(); var model2 = bll.GetAllList(id).First(); string zwone = getZWOne(model2.zt.ToString(), user); if (zwone == "未知") { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "未知职位" }); } var model = new sqshModel(); model.type = "出差报销"; //添加 查询与添加一致就行 model.sqid = Convert.ToInt32(id); model.spr = user.TrueName; model.sptime = DateTime.Now; model.spnr = yj; model.zt = (ty == "1") ? "通过" : "不通过"; model.spzw = zwone; new BLL.sqshBll().Add(model); //微信消息通知 wxxx(model2.id, model2.sqrid, model2.ksmc, model2.sqr, model2.bz, model, user.UserName); return Newtonsoft.Json.JsonConvert.SerializeObject(bll.opSp(id, user.ID, user.TrueName, yj, (ty == "1") ? true : false)); } #endregion #region 借款 [AllowAnonymous] public string getsqjk(string key, string id, string username) { string where; if (!string.IsNullOrEmpty(id)) { where = " id=" + id; } else { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; List zws = getZW(user); //非职务人员 if (zws.Count == 0) return Newtonsoft.Json.JsonConvert.SerializeObject(null); where = "(1=2"; foreach (string zw in zws) { switch (zw) { case "1": where += " or (zt=1 and exists (select 1 from oa..erpbumen where id=ksid and chargeMan='" + user.UserName + "'))"; break; case "2": where += " or (zt=2 and ksid in " + getChildrenKsid(user.ksid) + ") "; break; case "7": where += " or (zt=7 and ksid in " + getChildrenKsid(user.ksid) + ") "; break; } } where += ")"; if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } } var bll = new BLL.sqjkBll(); int count = bll.getCountLevel(where); var models = bll.getPageLevel(1, 1000, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } [AllowAnonymous] public string getsqjkmx(string key, string key1, string id) { var bllmx = new BLL.sqjkBll(); var modelmx = bllmx.GetAllList(id); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = modelmx }); } [AllowAnonymous] public string savesqjk(string id, string username, string yj, string ty) { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; var bll = new BLL.sqjkBll(); var model2 = bll.GetAllList(id).First(); string zwone = getZWOne(model2.zt.ToString(), user); if (zwone == "未知") { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "未知职位" }); } var model = new sqshModel(); model.type = "借款申请"; //添加 查询与添加一致就行 model.sqid = Convert.ToInt32(id); model.spr = user.TrueName; model.sptime = DateTime.Now; model.spnr = yj; model.zt = (ty == "1") ? "通过" : "不通过"; model.spzw = zwone; new BLL.sqshBll().Add(model); //微信消息通知 wxxx(model2.id, model2.sqrid, model2.ksmc, model2.sqr, model2.bz, model, user.UserName); return Newtonsoft.Json.JsonConvert.SerializeObject(bll.opSp(id, user.ID, user.TrueName, yj, (ty == "1") ? true : false)); } #endregion #region 物资采购 [AllowAnonymous] // 获取物资采购列表 public string getwzcg(string key, string id, string username) { string where; if (!string.IsNullOrEmpty(id)) { where = " id=" + id; } else { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; List zws = getZW(user); //非职务人员 if (zws.Count == 0) return Newtonsoft.Json.JsonConvert.SerializeObject(null); where = "(1=2"; foreach (string zw in zws) { switch (zw) { case "1": where += " or (zt=1 and exists (select 1 from oa..erpbumen where id=ksid and chargeMan='" + user.UserName + "'))"; break; case "2": where += " or (zt=2 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; case "7": where += " or (zt=7 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; } } where += ")"; if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } } var bll = new BLL.sqwzcgBll(); int count = bll.getCountLevel(where); var models = bll.getPageLevel(1, 1000, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } [AllowAnonymous] // 获取物资采购明细 public string getwzcgmx(string key, string key1, string id) { var bllmx = new BLL.sqwzcgmxBll(); var modelmx = bllmx.GetListByParent(id); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = modelmx }); } [AllowAnonymous] // 物资采购保存 public string savewzcg(string id, string yj, string ty, string username) { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; var bll = new BLL.sqwzcgBll(); var model2 = bll.GetAllList(id).First(); string zwone = getZWOne(model2.zt.ToString(), user); if (zwone == "未知") { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "未知职位" }); } var model = new sqshModel(); model.type = "物资采购"; model.sqid = Convert.ToInt32(id); model.spr = user.TrueName; model.sptime = DateTime.Now; model.spnr = yj; model.zt = (ty == "1") ? "通过" : "不通过"; model.spzw = zwone; new BLL.sqshBll().Add(model); //微信消息通知 wxxx(model2.id, model2.sqrid, model2.ksmc, model2.sqr, model2.bz, model, user.UserName); return Newtonsoft.Json.JsonConvert.SerializeObject(bll.opSp(id, user.ID, user.TrueName, yj, (ty == "1") ? true : false)); } #endregion #region 维修 [AllowAnonymous] // 获取维修列表 public string getsqwx(string key, string id, string username) { string where; if (!string.IsNullOrEmpty(id)) { where = " id=" + id; } else { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; List zws = getZW(user); //非职务人员 if (zws.Count == 0) return Newtonsoft.Json.JsonConvert.SerializeObject(null); where = "(1=2"; foreach (string zw in zws) { switch (zw) { case "1": where += " or (zt=1 and exists (select 1 from oa..erpbumen where id=ksid and chargeMan='" + user.UserName + "'))"; break; case "2": where += " or (zt=2 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; case "7": where += " or (zt=7 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; } } where += ")"; if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } } var bll = new BLL.sqwxBll(); int count = bll.getCountLevel(where); var models = bll.getPageLevel(1, 1000, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } [AllowAnonymous] // 获取维修明细 public string getsqwxmx(string key, string key1, string id) { var bllmx = new BLL.sqwxBll(); var modelmx = bllmx.GetAllList(id); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = modelmx }); } [AllowAnonymous] // 维修保存 public string savesqwx(string id, string yj, string ty, string username) { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; var bll = new BLL.sqwxBll(); var model2 = bll.GetAllList(id).First(); string zwone = getZWOne(model2.zt.ToString(), user); if (zwone == "未知") { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "未知职位" }); } var model = new sqshModel(); model.type = "维修"; model.sqid = Convert.ToInt32(id); model.spr = user.TrueName; model.sptime = DateTime.Now; model.spnr = yj; model.zt = (ty == "1") ? "通过" : "不通过"; model.spzw = zwone; new BLL.sqshBll().Add(model); //微信消息通知 wxxx(model2.id, model2.sqrid, model2.ksmc, model2.sqr, model2.bz, model, user.UserName); return Newtonsoft.Json.JsonConvert.SerializeObject(bll.opSp(id, user.ID, user.TrueName, yj, (ty == "1") ? true : false)); } #endregion #region 加班用餐 [AllowAnonymous] // 获取加班用餐列表 public string getsqjbyc(string key, string id, string username) { string where; if (!string.IsNullOrEmpty(id)) { where = " id=" + id; } else { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; List zws = getZW(user); //非职务人员 if (zws.Count == 0) return Newtonsoft.Json.JsonConvert.SerializeObject(null); where = "(1=2"; foreach (string zw in zws) { switch (zw) { case "1": where += " or (zt=1 and exists (select 1 from oa..erpbumen where id=ksid and chargeMan='" + user.UserName + "'))"; break; case "2": where += " or (zt=2 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; case "7": where += " or (zt=7 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; } } where += ")"; if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } } var bll = new BLL.sqjbycBll(); int count = bll.getCountLevel(where); var models = bll.getPageLevel(1, 1000, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } [AllowAnonymous] // 获取加班用餐明细 public string getsqjbycmx(string key, string key1, string id) { var bllmx = new BLL.sqjbycBll(); var modelmx = bllmx.GetAllList(id); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = modelmx }); } [AllowAnonymous] // 加班用餐保存 public string savesqjbyc(string id, string yj, string ty, string username) { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; var bll = new BLL.sqjbycBll(); var model2 = bll.GetAllList(id).First(); string zwone = getZWOne(model2.zt.ToString(), user); if (zwone == "未知") { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "未知职位" }); } var model = new sqshModel(); model.type = "加班用餐"; model.sqid = Convert.ToInt32(id); model.spr = user.TrueName; model.sptime = DateTime.Now; model.spnr = yj; model.zt = (ty == "1") ? "通过" : "不通过"; model.spzw = zwone; new BLL.sqshBll().Add(model); //微信消息通知 wxxx(model2.id, model2.sqrid, model2.ksmc, model2.sqr, model2.bz, model, user.UserName); return Newtonsoft.Json.JsonConvert.SerializeObject(bll.opSp(id, user.ID, user.TrueName, yj, (ty == "1") ? true : false)); } #endregion #region 公务接待 [AllowAnonymous] // 获取公务接待列表 public string getsqgwjd(string key, string id, string username) { string where; if (!string.IsNullOrEmpty(id)) { where = " id=" + id; } else { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; List zws = getZW(user); //非职务人员 if (zws.Count == 0) return Newtonsoft.Json.JsonConvert.SerializeObject(null); where = "(1=2"; foreach (string zw in zws) { switch (zw) { case "1": where += " or (zt=1 and exists (select 1 from oa..erpbumen where id=ksid and chargeMan='" + user.UserName + "'))"; break; case "2": where += " or (zt=2 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; case "7": where += " or (zt=7 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; } } where += ")"; if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } } var bll = new BLL.sqgwjdBll(); int count = bll.getCountLevel(where); var models = bll.getPageLevel(1, 1000, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } [AllowAnonymous] // 获取公务接待明细 public string getsqgwjdmx(string key, string key1, string id) { var bllmx = new BLL.sqgwjdBll(); var modelmx = bllmx.GetAllList(id); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = modelmx }); } [AllowAnonymous] // 加班公务接待保存 public string savesqgwjd(string id, string yj, string ty, string username) { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; var bll = new BLL.sqgwjdBll(); var model2 = bll.GetAllList(id).First(); string zwone = getZWOne(model2.zt.ToString(), user); if (zwone == "未知") { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "未知职位" }); } var model = new sqshModel(); model.type = "公务接待"; model.sqid = Convert.ToInt32(id); model.spr = user.TrueName; model.sptime = DateTime.Now; model.spnr = yj; model.zt = (ty == "1") ? "通过" : "不通过"; model.spzw = zwone; new BLL.sqshBll().Add(model); //微信消息通知 wxxx(model2.id, model2.sqrid, model2.ksmc, model2.sqr, model2.bz, model, user.UserName); return Newtonsoft.Json.JsonConvert.SerializeObject(bll.opSp(id, user.ID, user.TrueName, yj, (ty == "1") ? true : false)); } #endregion #region 其他报销单 [AllowAnonymous] // 其他报销单列表 public string getsqqtbx(string key, string id, string username) { string where; if (!string.IsNullOrEmpty(id)) { where = " id=" + id; } else { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; List zws = getZW(user); //非职务人员 if (zws.Count == 0) return Newtonsoft.Json.JsonConvert.SerializeObject(null); where = "(1=2"; foreach (string zw in zws) { switch (zw) { case "1": where += " or (zt=1 and exists (select 1 from oa..erpbumen where id=ksid and chargeMan='" + user.UserName + "'))"; break; case "2": where += " or (zt=2 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; case "6": where += " or (zt=6)"; break; case "7": where += " or (zt=7 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; } } where += ")"; if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } } var bll = new BLL.sqqtbxBll(); int count = bll.getCountLevel(where); var models = bll.getPageLevel(1, 1000, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } [AllowAnonymous] // 获取其他报销单明细 public string getsqqtbxmx(string key, string key1, string id) { var bllmx = new BLL.sqqtbxmxBll(); var modelmx = bllmx.GetListByParent(id); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = modelmx }); } [AllowAnonymous] // 其他报销单保存 public string savesqqtbx(string id, string yj, string ty, string username) { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; var bll = new BLL.sqqtbxBll(); var model2 = bll.GetAllList(id).First(); string zwone = getZWOne(model2.zt.ToString(), user); if (zwone == "未知") { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "未知职位" }); } var model = new sqshModel(); model.type = "其他报销"; model.sqid = Convert.ToInt32(id); model.spr = user.TrueName; model.sptime = DateTime.Now; model.spnr = yj; model.zt = (ty == "1") ? "通过" : "不通过"; model.spzw = zwone; new BLL.sqshBll().Add(model); //微信消息通知 wxxx(model2.id, model2.sqrid, model2.ksmc, model2.sqr, model2.bz, model, user.UserName); return Newtonsoft.Json.JsonConvert.SerializeObject(bll.opSp(id, user.ID, user.TrueName, yj, (ty == "1") ? true : false)); } #endregion #region 物资采购报销单 [AllowAnonymous] // 其他报销单列表 public string getsqwzcgbx(string key, string id, string username) { string where; if (!string.IsNullOrEmpty(id)) { where = " id=" + id; } else { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; List zws = getZW(user); //非职务人员 if (zws.Count == 0) return Newtonsoft.Json.JsonConvert.SerializeObject(null); where = "(1=2"; foreach (string zw in zws) { switch (zw) { case "1": where += " or (zt=1 and exists (select 1 from oa..erpbumen where id=ksid and chargeMan='" + user.UserName + "'))"; break; case "2": where += " or (zt=2 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; case "6": where += " or (zt=6)"; break; case "7": where += " or (zt=7 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; } } where += ")"; if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } } var bll = new BLL.sqwzcgbxBll(); int count = bll.getCountLevel(where); var models = bll.getPageLevel(1, 1000, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } [AllowAnonymous] // 获取物资采购报销明细 public string getsqwzcgbxmx(string key, string key1, string id) { var bllmx = new BLL.sqwzcgbxmxBll(); var modelmx = bllmx.GetListByParent(id); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = modelmx }); } [AllowAnonymous] // 物资采购报销保存 public string savesqwzcgbx(string id, string yj, string ty, string username) { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; var bll = new BLL.sqwzcgbxBll(); var model2 = bll.GetAllList(id).First(); string zwone = getZWOne(model2.zt.ToString(), user); if (zwone == "未知") { return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "未知职位" }); } var model = new sqshModel(); model.type = "物资采购报销"; model.sqid = Convert.ToInt32(id); model.spr = user.TrueName; model.sptime = DateTime.Now; model.spnr = yj; model.zt = (ty == "1") ? "通过" : "不通过"; model.spzw = zwone; new BLL.sqshBll().Add(model); //微信消息通知 wxxx(model2.id, model2.sqrid, model2.ksmc, model2.sqr, model2.bz, model, user.UserName); return Newtonsoft.Json.JsonConvert.SerializeObject(bll.opSp(id, user.ID, user.TrueName, yj, (ty == "1") ? true : false)); } #endregion #region 物资采购报销单关联物资入库单 [AllowAnonymous] public string getrkds(string id) { if (string.IsNullOrEmpty(id)) return Newtonsoft.Json.JsonConvert.SerializeObject(null); var bllmx = new BLL.rkdBll(); string where = " id in (" + id + ")"; var modelmx = bllmx.getPageLevel(1, 1000, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = modelmx }); } [AllowAnonymous] public string getrkdsmx(string id) { if (string.IsNullOrEmpty(id)) return Newtonsoft.Json.JsonConvert.SerializeObject(null); var bllmx = new BLL.rkdmxBll(); string where = " rkdid in (" + id + ")"; var modelmx = bllmx.getByids(where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = modelmx }); } #endregion #region 申请审核合并 报销审核合并 //我的(申请)(申请报销合并) [AllowAnonymous] public string getsqsh(string key, string id, string username) { string where; if (!string.IsNullOrEmpty(id)) { where = " id=" + id; } else { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; where = " sqrid=" + user.ID; } if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } var bll = new BLL.sqhbBll(); int count = bll.getCounthb(where); var models = bll.getPagehb(1, 100, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } //待审核的(申请)(申请报销合并) [AllowAnonymous] public string getsqshhb(string key, string id, string username) { string where; if (!string.IsNullOrEmpty(id)) { where = " id=" + id; } else { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; List zws = getZW(user); //非职务人员 if (zws.Count == 0) return Newtonsoft.Json.JsonConvert.SerializeObject(null); where = "(1=2"; foreach (string zw in zws) { switch (zw) { case "1": where += " or (zt=1 and exists (select 1 from oa..erpbumen where id=ksid and chargeMan='" + user.UserName + "'))"; break; case "2": where += " or (zt=2 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; case "3": where += " or (zt=3)"; break; case "4": where += " or (zt=4)"; break; case "5": where += " or (zt=5)"; break; case "6": where += " or (zt=6)"; break; case "7": where += " or (zt=7 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; } } where += ")"; if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } } var bll = new BLL.sqhbBll(); int count = bll.getCounthb(where); var models = bll.getPagehb(1, 1000, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } //我参与的(申请)(申请报销合并) [AllowAnonymous] public string getsqhbcx2(string key, int page, int pagesize, string start, string end, string zt, string hblx, string all, string username) { string where = "1=1"; if (string.IsNullOrEmpty(all)) { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; where = "1=1 and (sprid1=" + user.ID + " or sprid2=" + user.ID + " or sprid3=" + user.ID + " or sprid4=" + user.ID + " or sprid5=" + user.ID + " or sprid6=" + user.ID + ")"; } if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } if (!string.IsNullOrEmpty(start)) { where += " and sqsj >='" + start + "'"; } if (!string.IsNullOrEmpty(end)) { where += " and sqsj <='" + end + " 23:59:59'"; } if (!string.IsNullOrEmpty(zt)) { where += " and zt=" + zt; } if (!string.IsNullOrEmpty(hblx)) { where += " and hblx='" + hblx + "'"; } var bll = new BLL.sqhbBll(); int count = bll.getCounthb2(where); var models = bll.getPagehb2(page, pagesize, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } [AllowAnonymous] public string getCounthb(string username) { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; string where = " sqrid = " + user.ID; var bll = new BLL.sqhbBll(); int count = bll.getCounthb(where); var bll2 = new BLL.sqhbBll(); where = "1=1 and (sprid1=" + user.ID + " or sprid2=" + user.ID + " or sprid3=" + user.ID + " or sprid4=" + user.ID + " or sprid5=" + user.ID + " or sprid6=" + user.ID + ")"; int count2 = bll2.getCounthb2(where); var bll3 = new MedicalAppointmentBll(); var count3 = bll3.getyyCount("", "", "0", 49, 0); var list = new BLL.ProfessionalExamRegisterBll().getKSBZList("", "", "", "", "", ""); var count4 = list.Count; int count5 = GetJmsqList2("", "", username); return Newtonsoft.Json.JsonConvert.SerializeObject(new { count = count, count2 = count2, count3 = count3, count4 = count4, count5 = count5 }); } //我的(报销) [AllowAnonymous] public string getbxsh(string key, string id, string username) { string where; if (!string.IsNullOrEmpty(id)) { where = " id=" + id; } else { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; where = " sqrid=" + user.ID; } if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } var bll = new BLL.sqhbBll(); int count = bll.getCountbx(where); var models = bll.getPagebx(1, 1000, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } //待审核的(报销) [AllowAnonymous] public string getbxshhb(string key, string id, string username) { string where; if (!string.IsNullOrEmpty(id)) { where = " id=" + id; } else { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; List zws = getZW(user); //非职务人员 if (zws.Count == 0) return Newtonsoft.Json.JsonConvert.SerializeObject(null); where = "(1=2"; foreach (string zw in zws) { switch (zw) { case "1": where += " or (zt=1 and exists (select 1 from oa..erpbumen where id=ksid and chargeMan='" + user.UserName + "'))"; break; case "2": where += " or (zt=2 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; case "3": where += " or (zt=3)"; break; case "4": where += " or (zt=4)"; break; case "5": where += " or (zt=5)"; break; case "6": where += " or (zt=6)"; break; case "7": where += " or (zt=7 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; } } where += ")"; if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } } var bll = new BLL.sqhbBll(); int count = bll.getCountbx(where); var models = bll.getPagebx(1, 1000, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } //我参与的(报销) [AllowAnonymous] public string getbxhbcx2(string key, int page, int pagesize, string start, string end, string zt, string hblx, string all, string username) { string where = "1=1"; if (string.IsNullOrEmpty(all)) { var user = new ERPUserBll().login(username, ""); user.ksid = new ERPBuMenBll().GetAllList(user.Department)[0].ID; where = "1=1 and (sprid1=" + user.ID + " or sprid2=" + user.ID + " or sprid3=" + user.ID + " or sprid4=" + user.ID + " or bxrid=" + user.ID + ")"; } if (!string.IsNullOrEmpty(key)) { where += " and (sqr like '%" + key + "%' or sqdh like '%" + key + "%')"; } if (!string.IsNullOrEmpty(start)) { where += " and sqsj >='" + start + "'"; } if (!string.IsNullOrEmpty(end)) { where += " and sqsj <='" + end + " 23:59:59'"; } if (!string.IsNullOrEmpty(zt)) { where += " and zt=" + zt; } if (!string.IsNullOrEmpty(hblx)) { where += " and hblx='" + hblx + "'"; } var bll = new BLL.sqhbBll(); int count = bll.getCountbx2(where); var models = bll.getPagebx2(page, pagesize, where); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = count, Rows = models }); } #endregion #region 公共 //科室领导、分管领导、内审员、所有会签、备案人、财务、中心主任 //string[] zws = new string[] { "科室领导", "分管领导", "内审员", "会签", "备案人", "财务", "中心主任" }; private List getZW(ERPUser user) { string[] zws = user.ZhiWei.Split(','); //string[] zws = new string[] { "科室领导", "分管领导", "内审员", "会签", "备案人", "财务", "中心主任" }; List zwss = new List(); if (zws.Contains("科室领导")) zwss.Add("1"); if (zws.Contains("分管领导")) zwss.Add("2"); if (zws.Contains("内审员")) zwss.Add("3"); if (zws.Contains("会签")) zwss.Add("4"); if (zws.Contains("备案人")) zwss.Add("5"); if (zws.Contains("财务")) zwss.Add("6"); if (zws.Contains("中心主任")) zwss.Add("7"); return zwss; } private string getZWOne(string current, ERPUser user) { string[] zws = user.ZhiWei.Split(','); //string[] zws = new string[] { "科室领导", "分管领导", "内审员", "会签", "备案人", "财务", "中心主任" }; List zwss = new List(); if (zws.Contains("科室领导") && current == "1") return "科室领导"; if (zws.Contains("分管领导") && current == "2") return "分管领导"; if (zws.Contains("内审员") && current == "3") return "内审员"; if (zws.Contains("会签") && current == "4") return "会签"; if (zws.Contains("备案人") && current == "5") return "备案人"; if (zws.Contains("财务") && current == "6") return "财务"; if (zws.Contains("中心主任") && current == "7") return "中心主任"; return "未知"; } //得到所有子科室id private string getChildrenKsid(int ksid) { var bll = new BLL.ERPBuMenBll(); List result = bll.GetAllChildren(ksid.ToString()); string result2 = string.Join(",", result); return " (" + result2 + ")"; } //发送微信消息 需要所有关联的openid //select openid from ERPUser where id = 32 //select openid from ERPUser where zhiwei like '%中心主任%' //select openid from ERPUser where zhiwei like '%科室领导%' and department = '财务科' //select openid from ERPUser where zhiwei like '%分管领导%' and department = (select bumenname from erpbumen where id=(select dirid from erpbumen where bumenname='监督一科')) //select openid from ERPUser where zhiwei like '%内审员%' //select openid from ERPUser where zhiwei like '%备案人%' //select openid from ERPUser where zhiwei like '%财务%' private void wxxx(int id, int sqrid, string sqks, string sqr, string bz, sqshModel model, string sprusername) { //"科室领导", "分管领导", "内审员", "会签", "备案人", "财务", "中心主任" string sql = ""; var bll = new ERPUserBll(); string template_id = ""; string token = ""; //通知前 处理掉自己的提醒 改成已读 new BLL.ERPLanEmailBll().update(model.type + "|" + id.ToString(), sprusername); //通知审核人 (只通过通知) if (model.zt == "通过") { switch (model.spzw) { case "科室领导": sql = "select * from ERPUser where zhiwei like '%分管领导%' and department = (select bumenname from erpbumen where id = (select dirid from erpbumen where bumenname = '" + sqks + "'))"; break; case "分管领导": sql = "select * from ERPUser where zhiwei like '%中心主任%'"; if (model.type == "出差报销" || model.type == "物资采购报销" || model.type == "其他报销") { sql = "select * from ERPUser where zhiwei like '%财务%'"; } else if (model.type == "三重一大申请") { sql = "select * from ERPUser where zhiwei like '%内审员%'"; } break; case "内审员": sql = "select * from ERPUser where zhiwei like '%备案人%'"; break; case "备案人": sql = "select * from ERPUser where zhiwei like '%中心主任%'"; break; case "财务": sql = "select * from ERPUser where zhiwei like '%中心主任%'"; break; case "中心主任": if (model.type == "出差报销" || model.type == "物资采购报销" || model.type == "其他报销") { sql = "select * from ERPUser where zhiwei like '%出纳员%'"; } else if (model.type == "物资采购") { sql = "select * from ERPUser where zhiwei like '%总务科%'"; } break; } if (!string.IsNullOrEmpty(sql)) { List models = bll.getOpenids(sql); if (models.Count > 0) { foreach (ERPUser m in models) { //系统消息 ERPLanEmailModel modelxx = new ERPLanEmailModel(); modelxx.EmailTitle = "【" + sqr + "】的" + model.type + "需要你的审核"; modelxx.TimeStr = DateTime.Now; modelxx.EmailContent = model.sptime.ToString("yyyy-MM-dd HH:mm") + " " + model.spr + " " + model.spzw + "已审核
" + "申请内容:" + bz; modelxx.FuJian = ""; modelxx.FromUser = "审核消息"; modelxx.ToUser = m.UserName; modelxx.EmailState = "未读"; modelxx.type = model.type + "|" + id.ToString(); new BLL.ERPLanEmailBll().save(modelxx); if (!string.IsNullOrEmpty(m.Openid)) { template_id = "FsZ3HSb-NNxR3Qu13t3pTU-LV5wxeAv9wp6whyjQc28"; token = dccdc.Common.Global.getAccessToken.access_token; if (m.Openidtype == 1) //疫苗公众号 { template_id = "Pa3LFO_jV4z4mbFyMtGVbI6warV7CFbCatGtLVgAqDY"; token = dccdc.Common.Global.getAccessTokenYM.access_token; } try { var data = new { touser = m.Openid, template_id = template_id, url = "http://dc.51csharp.com/default.aspx?tjlogout=ok&yhid=" + m.ID.ToString(), miniprogram = new { appid = "wx85cc5d2f79a4ba6d", pagepath = "pages/index/index?hyid=" + m.ID.ToString() }, data = new { first = new { value = "【" + sqr + "】的" + model.type + "需要你的审核", color = "#173177" }, keyword1 = new { value = model.spr, color = "#173177" }, keyword2 = new { value = model.sptime.ToString("yyyy-MM-dd HH:mm"), color = "#173177" }, keyword3 = new { value = model.spzw + "已审核", color = "#173177" }, remark = new { value = "申请内容:" + bz, color = "#173177" }, } }; WebClient wc = new WebClient(); byte[] responseBytes = wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data))); string responseText = System.Text.Encoding.UTF8.GetString(responseBytes); } catch (Exception ex) { } } } } } } //通知本人 sql = "select * from ERPUser where id = " + sqrid; List models2 = bll.getOpenids(sql); if (models2.Count > 0) { //系统消息 ERPLanEmailModel modelxx = new ERPLanEmailModel(); modelxx.EmailTitle = "你的" + model.type + "申请已被【" + model.spzw + ":" + model.spr + "】" + (model.zt == "通过" ? "审核通过" : "驳回"); modelxx.TimeStr = DateTime.Now; modelxx.EmailContent = model.sptime.ToString("yyyy-MM-dd HH:mm") + " " + model.spr + "
" + "审批内容:" + model.spnr; modelxx.FuJian = ""; modelxx.FromUser = "审核消息"; modelxx.ToUser = models2[0].UserName; modelxx.EmailState = "未读"; modelxx.type = ""; new BLL.ERPLanEmailBll().save(modelxx); if (!string.IsNullOrEmpty(models2[0].Openid)) { template_id = "FsZ3HSb-NNxR3Qu13t3pTU-LV5wxeAv9wp6whyjQc28"; token = dccdc.Common.Global.getAccessToken.access_token; if (models2[0].Openidtype == 1) //疫苗公众号 { template_id = "Pa3LFO_jV4z4mbFyMtGVbI6warV7CFbCatGtLVgAqDY"; token = dccdc.Common.Global.getAccessTokenYM.access_token; } try { var data = new { touser = models2[0].Openid, template_id = template_id, url = "http://dc.51csharp.com/default.aspx?tjlogout=ok&yhid=" + models2[0].ID.ToString(), miniprogram = new { appid = "wx85cc5d2f79a4ba6d", pagepath = "pages/index/index?hyid=" + models2[0].ID.ToString(), }, data = new { first = new { value = "你的" + model.type + "申请已被【" + model.spzw + ":" + model.spr + "】" + (model.zt == "通过" ? "审核通过" : "驳回"), color = "#173177" }, keyword1 = new { value = model.spr, color = "#173177" }, keyword2 = new { value = model.sptime.ToString("yyyy-MM-dd HH:mm"), color = "#173177" }, keyword3 = new { value = "申请内容:" + bz, color = "#173177" }, remark = new { value = "审批内容:" + model.spnr, color = "#173177" }, } }; WebClient wc = new WebClient(); byte[] responseBytes = wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data))); string responseText = System.Text.Encoding.UTF8.GetString(responseBytes); } catch (Exception ex) { } } } } //获取验证码 [AllowAnonymous] public string getCode(string username) { Random rd = new Random(); string yzm = rd.Next(100000, 999999).ToString(); ///////////////////////////////////////////////////////////////// 短信验证码 //var commonbll = new BLL.Common(); ////发送短信 ////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 = commonbll.getParm_Value("zxshdxtz", "18863836559", "疾控中心审核短信通知"); //req.sign = commonbll.getParm_Value("yddxsign", "d37CYmrbG", "签名编码"); ////req.content = "您报销审核的验证码是:{[yzm:数字+英文符号,总长度6]},请小心保管,不要告诉他人。"; //req.templateId = "aded61e87ea940e2a6c0851e1c68bdb4"; //req.addSerial = ""; //string[] parms = new string[1]; //parms[0] = yzm; //req.parms = Newtonsoft.Json.JsonConvert.SerializeObject(parms); //var md5 = System.Security.Cryptography.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"); //log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(upstr); //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)); //////////////////////////////////////////////////////////////// 公众号验证码 var model = new ERPUserBll().login(username, ""); if (model != null && !string.IsNullOrEmpty(model.Openid)) { string template_id = "FsZ3HSb-NNxR3Qu13t3pTU-LV5wxeAv9wp6whyjQc28"; string token = dccdc.Common.Global.getAccessToken.access_token; if (model.Openidtype == 1) //疫苗公众号 { template_id = "Fxodt7EjNuGdUAc4X5eqGG2TIL5TlNfq6wrY_eFP0t0"; token = dccdc.Common.Global.getAccessTokenYM.access_token; } try { var data = new { touser = model.Openid, template_id = template_id, url = "http://dc.51csharp.com/default.aspx?tjlogout=ok&yhid=" + model.ID.ToString(), miniprogram = new { appid = "wx85cc5d2f79a4ba6d", pagepath = "pages/index/index?hyid=" + model.ID.ToString(), }, data = new { first = new { value = "疾控审核验证码已生成", color = "#173177" }, keyword1 = new { value = model.TrueName, color = "#173177" }, keyword2 = new { value = yzm, color = "#173177" }, remark = new { value = "", color = "#173177" }, } }; WebClient wc = new WebClient(); byte[] responseBytes = wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data))); string responseText = System.Text.Encoding.UTF8.GetString(responseBytes); } catch (Exception ex) { } } return yzm; } #endregion #region 小程序按钮显示权限 [AllowAnonymous] // 获取经费申请列表 public string getXCX(string username) { var user = new ERPUserBll().login(username, ""); return user.Xcx; } [AllowAnonymous] public string getXCXimg() { var bll = new BLL.xcximgBll(); var models = bll.GetAllList(); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = models }); } #endregion #region 附件 //sqid=0 要加上用户id 存在sqid就不需要用户id [AllowAnonymous] public string getSqfile(string type, string sqid) { var bll = new BLL.sqfileBll(); var models = bll.GetListByKey(type, sqid, "0"); return Newtonsoft.Json.JsonConvert.SerializeObject(new { Total = 0, Rows = models }); } [AllowAnonymous] public string savelog(string type, string id, string sqid, string username) { var user = new ERPUserBll().login(username, ""); var bll = new BLL.sqfileBll(); bll.savelog(id, user.TrueName); var models = bll.GetListByKey(type, sqid, "0"); int have = 0; foreach (var model in models) { if (!model.downlog.Contains(user.TrueName)) { have = 1; break; } } return have.ToString(); } #endregion #region [AllowAnonymous] public JsonResult setImg(string id, string imgData) { //return Json(new { id = id, imgData = imgData }); if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(imgData)) { return Json(new { State = 0, Message = "参数错误" }); } try { CacheHelper.SetCache(id, imgData, 600); //保存图片文件 byte[] bytes = Convert.FromBase64String(imgData.Split(',')[1]); string path = Server.MapPath("/UploadFile/xcx2/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } using (Image img = Image.FromStream(new MemoryStream(bytes))) { img.Save(path + id + ".png", ImageFormat.Png); } return Json(new { State = 1, Message = "操作成功", path = "/UploadFile/xcx2/" + id + ".png" }); } catch (Exception ex) { return Json(new { State = 0, Message = ex.Message }); } } [AllowAnonymous] public string getCodeid() { Random rd = new Random(); return DateTime.Now.ToString("yyMMddHHmmssff") + "-" + rd.Next(10, 100); } [AllowAnonymous] public FileResult getCode2(string id) { //string url = "https://oa.dcqcdc.com/dccdc/wxapp/setImg|"; string url = ConfigurationManager.AppSettings["rooturl"] + "/dccdc/wxapp/setImg|"; //将json串做成二维码 Encoding e8859Encode = Encoding.GetEncoding("iso-8859-1"); Encoding srcEncode = Encoding.Unicode; Encoding dstEncode = Encoding.GetEncoding("utf-8"); byte[] srcBytes = srcEncode.GetBytes(url + id); byte[] dstBytes = Encoding.Convert(srcEncode, dstEncode, srcBytes); char[] dstChars = new char[e8859Encode.GetCharCount(dstBytes, 0, dstBytes.Length)]; e8859Encode.GetChars(dstBytes, 0, dstBytes.Length, dstChars, 0); ZXing.QrCode.QRCodeWriter qw = new ZXing.QrCode.QRCodeWriter(); var code = qw.encode(new string(dstChars), ZXing.BarcodeFormat.QR_CODE, 151, 151); ZXing.BarcodeWriter bw = new ZXing.BarcodeWriter(); var b = bw.Write(code); try { using (MemoryStream stream = new MemoryStream()) { b.Save(stream, ImageFormat.Jpeg); byte[] data = new byte[stream.Length]; stream.Seek(0, SeekOrigin.Begin); stream.Read(data, 0, Convert.ToInt32(stream.Length)); return File(data, "image/jpeg"); } } catch (Exception ex) { return File("../Images/signation2.png", "image/jpeg"); } } [AllowAnonymous] public string get(string id) { string result = ""; try { result = CacheHelper.GetCache(id) == null ? "" : CacheHelper.GetCache(id).ToString(); } catch (Exception ex) { result = ex.Message; } return result; } [AllowAnonymous] public FileResult getCode22(string id) { //string url = "https://oa.dcqcdc.com/dccdc/wxapp/rgyy2?id="; string url = ConfigurationManager.AppSettings["rooturl"] + "/dccdc/wxapp/rgyy2?id="; //将json串做成二维码 Encoding e8859Encode = Encoding.GetEncoding("iso-8859-1"); Encoding srcEncode = Encoding.Unicode; Encoding dstEncode = Encoding.GetEncoding("utf-8"); byte[] srcBytes = srcEncode.GetBytes(url + id); byte[] dstBytes = Encoding.Convert(srcEncode, dstEncode, srcBytes); char[] dstChars = new char[e8859Encode.GetCharCount(dstBytes, 0, dstBytes.Length)]; e8859Encode.GetChars(dstBytes, 0, dstBytes.Length, dstChars, 0); ZXing.QrCode.QRCodeWriter qw = new ZXing.QrCode.QRCodeWriter(); var code = qw.encode(new string(dstChars), ZXing.BarcodeFormat.QR_CODE, 151, 151); ZXing.BarcodeWriter bw = new ZXing.BarcodeWriter(); var b = bw.Write(code); try { using (MemoryStream stream = new MemoryStream()) { b.Save(stream, ImageFormat.Jpeg); byte[] data = new byte[stream.Length]; stream.Seek(0, SeekOrigin.Begin); stream.Read(data, 0, Convert.ToInt32(stream.Length)); return File(data, "image/jpeg"); } } catch (Exception ex) { return File("../Images/signation2.png", "image/jpeg"); } } [AllowAnonymous] public ActionResult rgyy2(string id) { ViewBag.id = id; return View(); } #endregion } }