using System; using System.Collections.Generic; using System.Linq; using System.Text; using EAS.Data; using EAS.Services; using SOH.Entities; using EAS.Data.Access; using EAS; using SOH.Entities.DTO; using SOH.Data; using EAS.Data.Linq; using EAS.Data.ORM; using System.Data; namespace SOH.BLL { [ServiceObject("收费功能")] [ServiceBind(typeof(IShouFei))] public class ShouFeiBll : IShouFei { public List getXuYaoShouFei(short fddm) { //throw new NotImplementedException(); using (var db = new DbEntities()) { //select tcbm,czjjxbj,tm,hyh,xm,xb,nl,tmztz,tjzje,tczje,tckxfbz,tjlb from t_grgzb //where tmztz=1 and fddm=2 order by xm var tt_dj = db.t_ttgzbs.Where(t => t.fddm == fddm && (t.tmztz == 1 || t.tmztz == 3)) .Select(t => new dto_gzb { tm = t.tm, xm = t.xm, lx = 2, nl = t.nl, sfzh = t.sfzh, csrq = t.csrq, hyh = t.hyh, hyzk = t.hyzk, xb = t.xb, ygbh = t.ygh, ygbm = t.ssbm, ygdh = t.tel, tjzje = t.tjzje / 100.0, tmztz = t.tmztz }).ToList(); var gr_dj = db.t_grgzbs.Where(t => t.fddm == fddm && (t.tmztz == 1 || t.tmztz == 3)) .Select(t => new dto_gzb { tm = t.tm, xm = t.xm, lx = 1, nl = t.nl, sfzh = t.sfzh, csrq = t.csrq, hyh = t.hyh, hyzk = t.hyzk, xb = t.xb, tjzje = t.tjzje / 100.0, tcbm = t.tcbm, tczl = t.tczl, tmztz = t.tmztz }).ToList(); return tt_dj.Concat(gr_dj).OrderBy(t => t.xm).ToList(); } } public List getXuYaoShouFei(short fddm, int hyh) { //throw new NotImplementedException(); using (var db = new DbEntities()) { //select tcbm,czjjxbj,tm,hyh,xm,xb,nl,tmztz,tjzje,tczje,tckxfbz,tjlb from t_grgzb //where tmztz=1 and fddm=2 order by xm var tt_dj = db.t_ttgzbs.Where(t => t.hyh == hyh && t.fddm == fddm && (t.tmztz == 1 || t.tmztz == 3)) .Select(t => new dto_gzb { tm = t.tm, xm = t.xm, lx = 2, lxmc = "团检", nl = t.nl, sfzh = t.sfzh, csrq = t.csrq, hyh = t.hyh, hyzk = t.hyzk, xb = t.xb, ygbh = t.ygh, ygbm = t.ssbm, ygdh = t.tel, tjzje = t.tjzje / 100.0, tmztz = t.tmztz }).ToList(); var gr_dj = db.t_grgzbs.Where(t => t.hyh == hyh && t.fddm == fddm && (t.tmztz == 1 || t.tmztz == 3)) .Select(t => new dto_gzb { tm = t.tm, xm = t.xm, lx = 1, lxmc = "个检", nl = t.nl, sfzh = t.sfzh, csrq = t.csrq, hyh = t.hyh, hyzk = t.hyzk, xb = t.xb, tjzje = t.tjzje / 100.0, tcbm = t.tcbm, tczl = t.tczl, tmztz = t.tmztz }).ToList(); return tt_dj.Concat(gr_dj).OrderBy(t => t.xm).ToList(); } } /// /// 获取待检人员列表信息 /// /// /// public List Getdjry(short fddm, string xm) { //throw new NotImplementedException(); using (var db = new DbEntities()) { //select tcbm,czjjxbj,tm,hyh,xm,xb,nl,tmztz,tjzje,tczje,tckxfbz,tjlb from t_grgzb //where tmztz=1 and fddm=2 order by xm var tt_dj = db.t_ttgzbs.Where(t => t.fddm == fddm && (t.tmztz == -2) && t.xm.Contains(xm)) .Select(t => new dto_gzb { tm = t.tm, xm = t.xm, lx = 2, nl = t.nl, sfzh = t.sfzh, csrq = t.csrq, hyh = t.hyh, hyzk = t.hyzk, xb = t.xb, ygbh = t.ygh, ygbm = t.ssbm, ygdh = t.tel, tjzje = t.tjzje / 100.0, tmztz = t.tmztz }).ToList(); var gr_dj = db.t_grgzbs.Where(t => t.fddm == fddm && (t.tmztz == -2) && t.xm.Contains(xm)) .Select(t => new dto_gzb { tm = t.tm, xm = t.xm, lx = 1, nl = t.nl, sfzh = t.sfzh, csrq = t.csrq, hyh = t.hyh, hyzk = t.hyzk, xb = t.xb, tjzje = t.tjzje / 100.0, tcbm = t.tcbm, tczl = t.tczl, tmztz = t.tmztz }).ToList(); return tt_dj.Concat(gr_dj).OrderBy(t => t.xm).ToList(); } } /// /// 获取待检人员列表信息根据身份证 /// /// /// public List GetdjryBySfzh(short fddm, string sfzh) { //throw new NotImplementedException(); using (var db = new DbEntities()) { //select tcbm,czjjxbj,tm,hyh,xm,xb,nl,tmztz,tjzje,tczje,tckxfbz,tjlb from t_grgzb //where tmztz=1 and fddm=2 order by xm var tt_dj = db.t_ttgzbs.Where(t => t.fddm == fddm && (t.tmztz == -2) && t.sfzh == sfzh) .Select(t => new dto_gzb { tm = t.tm, xm = t.xm, lx = 2, nl = t.nl, sfzh = t.sfzh, csrq = t.csrq, hyh = t.hyh, hyzk = t.hyzk, xb = t.xb, ygbh = t.ygh, ygbm = t.ssbm, ygdh = t.tel, tjzje = t.tjzje / 100.0, tmztz = t.tmztz }).ToList(); var gr_dj = db.t_grgzbs.Where(t => t.fddm == fddm && (t.tmztz == -2) && t.sfzh == sfzh) .Select(t => new dto_gzb { tm = t.tm, xm = t.xm, lx = 1, nl = t.nl, sfzh = t.sfzh, csrq = t.csrq, hyh = t.hyh, hyzk = t.hyzk, xb = t.xb, tjzje = t.tjzje / 100.0, tcbm = t.tcbm, tczl = t.tczl, tmztz = t.tmztz }).ToList(); return tt_dj.Concat(gr_dj).OrderBy(t => t.xm).ToList(); } } public string getjjxmxbytm(int tm) { return getjjxmxbytm(tm, 0); //throw new NotImplementedException(); } public Data.OperationResult ShouFei(dto_gzb gzb, List sfmxs, short fddm, string czy, int zje, string isOpen, string sfczy) { //throw new NotImplementedException(); int zje100 = zje * 100; short sfjx = 0; OperationResult or = new OperationResult(); using (var db = new DbEntities()) { var tran = db.CreateTransaction(); try { int lo = 0; if (gzb.tmztz == 3) { sfjx = 1; } if (gzb.lx == 1) { lo = db.DataAccessor.Execute("update t_grgzb set tmztz=2,upflag=1,tjrq=getdate(),tjzje=tjzje+" + zje100 + " where (tmztz=1 or tmztz=3) and tm=" + gzb.tm); if (lo <= 0) { tran.Rollback(); or.State = 0; or.Message = "当前条码状态不能进行收费操作!"; return or; } } else if (gzb.lx == 2) { //update t_ttgzb set tmztz=2,upflag=1 where tm=1000194142 lo = db.DataAccessor.Execute("update t_ttgzb set tmztz=2,upflag=1,tjzje=tjzje+" + zje100 + " where (tmztz=1 or tmztz=3) and tm=" + gzb.tm); if (lo <= 0) { tran.Rollback(); or.State = 0; or.Message = "当前条码状态不能进行收费操作!"; return or; } } var grgzb = db.t_grgzbs.FirstOrDefault(t => t.tm == gzb.tm); int xh = new BasicBll().GetMax(new t_sfmxb().DbTableName, sfmxs.Count); foreach (var sf in sfmxs) { var sfmx = new t_sfmxb(); //insert into t_sfmxb (xh,tm,sffs,je,czy,tjrq,hslx,hsname,sffx,fddm) values(48479,0000216185,0,600,'admin','2015-8-10','0','系统管理员',0,2) // sfmx.xh = xh++; sfmx.fddm = fddm; sfmx.je = sf.je; sfmx.sffs = sf.lx; sfmx.czy = czy; sfmx.tjrq = DateTime.Now; sfmx.hslx = 0; sfmx.hsname = gzb.lx == 1 ? grgzb.xiaoshou : ""; sfmx.sffx = 0; sfmx.fddm = fddm; sfmx.tm = gzb.tm; db.t_sfmxbs.Insert(sfmx); } /* * select tm from t_tempdjxm where tm=0000216186 and zhbm=391 go insert into t_tempdjxm (tm,zhbm,ksbm,djrq,ztz,fddm) values(0000216186,391,39,'2015-8-12',0,2) go update t_tempdjxm set ztz=4,upflag=1 from t_tempdjxm,t_zhxm where t_tempdjxm.zhbm=t_zhxm.zhbm and t_zhxm.jclb=2 and tm=0000216186 */ string zhxmmc = ""; List zhbmList = new List(); DataTable dt = Newtonsoft.Json.JsonConvert.DeserializeObject(getjjxmxbytm(gzb.tm, 1)); if (dt.Rows.Count > 0) { DataRow[] drs = dt.Select("jjx=1"); foreach (DataRow dr in drs) { DataRow[] drs1 = dt.Select("jjx=-1 and zhbm=" + dr["zhbm"].ToString()); if (drs1.Length > 0) { dt.Rows.Remove(drs1[0]); } dt.Rows.Remove(dr); } } foreach (DataRow dr in dt.Rows) { int zhbm = int.Parse(dr["zhbm"].ToString()); zhbmList.Add(zhbm); if (dr["jjx"].ToString() == "0") { string zhxmmcSql = "select zhmc from t_zhxm where zhbm=" + zhbm; zhxmmc += db.DataAccessor.QueryScalar(zhxmmcSql).ToString() + "\r\n"; } int ksbm = int.Parse(dr["ksbm"].ToString()); string jgstr = dr["jg"].ToString(); string zhjgstr = dr["jjxje"].ToString(); int jg = (int)double.Parse(jgstr); int zhjg = (int)double.Parse(zhjgstr); if (!db.t_tempdjxms.Where(p => p.tm == gzb.tm && p.zhbm == zhbm).Any()) { var tempdjxm = new t_tempdjxm(); tempdjxm.tm = gzb.tm; tempdjxm.zhbm = zhbm; tempdjxm.ksbm = ksbm; tempdjxm.djrq = DateTime.Now; tempdjxm.ztz = 0; //tempdjxm.czy = czy; tempdjxm.czy = ""; tempdjxm.upflag = 0; tempdjxm.fddm = fddm; tempdjxm.jg = jg * 100; tempdjxm.zhjg = zhjg * 100; db.t_tempdjxms.Insert(tempdjxm); } } lo = db.DataAccessor.Execute("update t_jjxb set ysfbz=1,upflag=1 where jjx=0 and ysfbz=0 and tm=" + gzb.tm); /* if (lo <= 0) { tran.Rollback(); or.State = 0; or.Message = "更改收费出错!"; return or; }*/ db.DataAccessor.Execute("update t_grgzb set jxqrzt=null,upflag=1 where tm=0"); //insert into t_drxpjl(xh,tm,hyh,xm,dw,tcorfzname, shouldpay,pay, cash, bank,jzcard, jzmoney,tccard,paper,nomoney,checkpaper,sftf,rq,sfjx) //values(33616,'0000216186','000208575','郑B','个人体检','自选套餐','6','6.00','3.00','1','','0.00', '', '0.00','0', '2', '0','2015-8-12',0) var drxp = new T_drxpjl(); drxp.xh = new BasicBll().GetMax(drxp.DbTableName, 1); drxp.tm = gzb.tm; drxp.hyh = gzb.hyh.ToString(); drxp.xm = gzb.xm; drxp.sfczy = sfczy; if (gzb.lx == 1) { drxp.dw = "个人体检"; if (sfjx == 0) { //int bm = Convert.ToInt16(grgzb.xiaoshou); //drxp.age = db.t_ygzds.Where(t => t.bm == bm).FirstOrDefault().xm; drxp.age = grgzb.doctor; string getTcmc = "select tcmc from t_tc where tcbm=" + gzb.tcbm; DataTable dts = db.DataAccessor.QueryDataTable(getTcmc); drxp.tcorfzname = dts.Rows[0][0].ToString().Trim(); } else { drxp.age = db.t_jxysjls.Where(t => t.tm == gzb.tm && zhbmList.Contains(t.zhbm)).Join(db.t_ygzds, t => t.ysbm, p => p.bm, (t, p) => new { xiaoshou = p.xm }).FirstOrDefault().xiaoshou; drxp.tcorfzname = zhxmmc; if (drxp.age == "无") { drxp.age = db.t_jxysjls.Where(t => t.tm == gzb.tm && zhbmList.Contains(t.zhbm)).Select(t => new { xiaoshou = t.ywdb }).FirstOrDefault().xiaoshou; } } drxp.jzmoney = grgzb.bz; } else { drxp.jzmoney = db.t_ttgzbs.Where(t => t.tm == gzb.tm).Join(db.t_hts, t => t.htbm, p => p.htbm, (t, p) => new { jzmoney = t.bz }).FirstOrDefault().jzmoney; drxp.dw = gzb.khmc; if (sfjx == 0) { drxp.tcorfzname = gzb.tcmc; drxp.age = db.t_ttgzbs.Where(t => t.tm == gzb.tm).Join(db.t_hts, t => t.htbm, p => p.htbm, (t, p) => new { xiaoshou = p.ywdbdm }).FirstOrDefault().xiaoshou; } else { drxp.age = db.t_jxysjls.Where(t => t.tm == gzb.tm && zhbmList.Contains(t.zhbm)).Join(db.t_ygzds, t => t.ysbm, p => p.bm, (t, p) => new { xiaoshou = p.xm }).FirstOrDefault().xiaoshou; drxp.tcorfzname = zhxmmc; if (drxp.age == "无") { drxp.age = db.t_jxysjls.Where(t => t.tm == gzb.tm && zhbmList.Contains(t.zhbm)).Select(t => new { xiaoshou = t.ywdb }).FirstOrDefault().xiaoshou; } } } /*if (!string.IsNullOrEmpty(gzb.tcmc)) { drxp.tcorfzname = gzb.tcmc; } else {*/ if (sfjx == 0) { string getTcmc = "select tcmc from t_tc where tcbm=" + gzb.tcbm; DataTable dts = db.DataAccessor.QueryDataTable(getTcmc); if (dts.Rows.Count != 0) { drxp.tcorfzname = dts.Rows[0][0].ToString().Trim(); } } else { drxp.tcorfzname = zhxmmc; } //} //收费金额 drxp.shouldpay = sfmxs.Sum(t => t.je).ToString(); //如果是现金 var xj = sfmxs.FirstOrDefault(t => t.lx == 0); drxp.pay = xj == null ? "0" : xj.je.ToString(); //如果是免费 var mf = sfmxs.FirstOrDefault(t => t.lx == 4); drxp.nomoney = mf == null ? "0" : mf.je.ToString(); //如果是挂账 var gz = sfmxs.FirstOrDefault(t => t.lx == 7); drxp.jzcard = gz == null ? "0" : gz.je.ToString(); //如果是银行卡 var yh = sfmxs.FirstOrDefault(t => t.lx == 1); drxp.bank = yh == null ? "0" : yh.je.ToString(); //如果是体检卡 var zp = sfmxs.FirstOrDefault(t => t.lx == 2); drxp.checkpaper = zp == null ? "0" : zp.je.ToString(); //如果是网上套餐 var tc = sfmxs.FirstOrDefault(t => t.lx == 5); drxp.tccard = tc == null ? "0" : tc.je.ToString(); //如果是售卡 var sk = sfmxs.FirstOrDefault(t => t.lx == 8); drxp.shouka = sk == null ? "0" : sk.je.ToString(); //如果是支付宝 var zfb = sfmxs.FirstOrDefault(t => t.lx == 3); drxp.cash = zfb == null ? "0" : zfb.je.ToString(); //如果是微信 var weixin = sfmxs.FirstOrDefault(t => t.lx == 6); drxp.sex = weixin == null ? "0" : weixin.je.ToString(); drxp.sftf = 0; drxp.sfjx = sfjx; drxp.rq = DateTime.Now; db.T_drxpjls.Insert(drxp); //update t_tempdjxm set ztz=4,upflag=1 from t_tempdjxm,t_zhxm where t_tempdjxm.zhbm=t_zhxm.zhbm and t_zhxm.jclb=2 and tm=0000216186 db.DataAccessor.Execute("update t_tempdjxm set ztz=4,upflag=1 from t_tempdjxm,t_zhxm where t_tempdjxm.zhbm=t_zhxm.zhbm and t_zhxm.jclb=2 and tm=" + gzb.tm); if (gzb.lx == 1) { db.DataAccessor.Execute("update t_grgzb set jxqrzt=null,upflag=1 where tm=0"); } tran.Commit(); if (isOpen == "1") { string ksname = PaiDuiJiaoHaoBLL.sendPaiduixinxi(gzb.tm); or.Tag = drxp.xh.ToString(); or.State = 1; or.Message = "收费成功!"; if (!string.IsNullOrEmpty(ksname)) { or.Message += "\r\n请到" + ksname + "体检"; } } else { or.Tag = drxp.xh.ToString(); or.State = 1; or.Message = "收费成功!"; } } catch (System.Exception ex) { tran.Rollback(); or.Tag = ""; or.State = 0; or.Message = ex.Message; return or; } } return or; } private string getjjxmxbytm(int tm, int v) { using (var db = new DbEntities()) { //select t_jjxb.zhbm,t_jjxb.jjx,t_jjxb.zl,t_jjxb.jjxje,t_jjxb.jglx,t_zhxm.ksbm,t_zhxm.jclb from t_jjxb,t_zhxm where t_zhxm.zhbm=t_jjxb.zhbm and tm=0000216185 var grgzb = db.t_grgzbs.FirstOrDefault(t => t.tm == tm); //var ttgzb = db.t_ttgzbs.FirstOrDefault(t => t.tm == tm); if (grgzb != null) { if (v == 1) { grgzb.tmztz = 1; } //return Newtonsoft.Json.JsonConvert.SerializeObject(zhxm); if (grgzb.tmztz == 1) { var zhxm = db.t_jjxbs.Where(t => t.tm == tm && t.ysfbz == 0).Join(db.t_zhxms, t => t.zhbm, p => p.zhbm, (o, p) => new { p.zhmc, zl = o.zl / 100.0, //jjxje = o.jjxje / 100.0*o.zl/100.0, jjxje = p.jg / 100.0 * o.zl / 100.0, jg = p.jg / 100.0, jjx = o.jjx, zhbm = o.zhbm, ksbm = p.ksbm }).ToList(); var tc = db.t_grgzbs.Where(t => t.tm == tm).Join(db.t_tcxmmxs, t => t.tcbm, p => p.tcbm, (t, p) => new { t.tczl, p.zhbm }) .Join(db.t_zhxms, t => t.zhbm, p => p.zhbm, (t, p) => new { p.zhmc, zl = t.tczl / 100.0, jjxje = p.jg * t.tczl / 100.0 / 100, jg = p.jg / 100.0, jjx = (short)-1, zhbm = p.zhbm, ksbm = p.ksbm }).ToList(); return Newtonsoft.Json.JsonConvert.SerializeObject(zhxm.Concat(tc)); } else { var zhxm = db.t_jjxbs.Where(t => t.tm == tm && t.ysfbz == 0 && t.jjx == 0).Join(db.t_zhxms, t => t.zhbm, p => p.zhbm, (o, p) => new { p.zhmc, zl = o.zl / 100.0, //jjxje = o.jjxje / 100.0 * o.zl / 100.0, jjxje = p.jg / 100.0 * o.zl / 100.0, jg = p.jg / 100.0, jjx = o.jjx, zhbm = o.zhbm, ksbm = p.ksbm }).ToList(); return Newtonsoft.Json.JsonConvert.SerializeObject(zhxm); } } var ttgzb = db.t_ttgzbs.FirstOrDefault(t => t.tm == tm); if (v == 1) { ttgzb.tmztz = 1; } if (ttgzb.tmztz == 1) { var zhxm = db.t_htxmbs.Where(t => t.htfzbm == ttgzb.htfzbm).Join(db.t_zhxms, t => t.zhbm, p => p.zhbm, (o, p) => new { p.zhmc, htfzbm = o.htfzbm, jg = p.jg / 100.0, jjxje = p.jg / 100.0, jjx = (short)-1, zhbm = o.zhbm, ksbm = p.ksbm }).Join(db.t_htfzbs, t => t.htfzbm, p => p.htfzbm, (o, p) => new { zl = p.fzzl, //jjxje = o.jjxje * p.fzzl / 100.0, jjxje = o.jg * p.fzzl / 100.0, o.jg, o.zhmc, o.zhbm, o.ksbm, o.jjx }) .ToList(); var jxzhxm = db.t_jjxbs.Where(t => t.tm == tm && t.ysfbz == 0 && t.jjx == 0).Join(db.t_zhxms, t => t.zhbm, p => p.zhbm, (o, p) => new { zl = o.zl, //jjxje = o.jjxje / 100.0*o.zl/100.0, jjxje = p.jg / 100.0 * o.zl / 100.0, jg = p.jg / 100.0, p.zhmc, zhbm = o.zhbm, ksbm = p.ksbm, jjx = o.jjx }).ToList(); return Newtonsoft.Json.JsonConvert.SerializeObject(zhxm.Concat(jxzhxm).ToList()); } else { var zhxm = db.t_jjxbs.Where(t => t.tm == tm && t.ysfbz == 0 && t.jjx == 0).Join(db.t_zhxms, t => t.zhbm, p => p.zhbm, (o, p) => new { p.zhmc, zl = o.zl / 100.0, //jjxje = o.jjxje / 100.0 * o.zl / 100.0, jjxje = p.jg / 100.0 * o.zl / 100.0, jg = p.jg / 100.0, jjx = o.jjx, zhbm = o.zhbm, ksbm = p.ksbm }).ToList(); return Newtonsoft.Json.JsonConvert.SerializeObject(zhxm); } } } public dto_htfz getkhfzbytm(int tmh) { //throw new NotImplementedException(); dto_htfz htfz = new dto_htfz(); using (var db = new DbEntities()) { var fzmc = db.t_ttgzbs.Where(t => t.tm == tmh) .Join(db.t_htfzbs, t => t.htfzbm, p => p.htfzbm, (t, p) => p.htfzmc).FirstOrDefault(); htfz.fzmc = fzmc; var khmc = db.t_ttgzbs.Where(t => t.tm == tmh) .Join(db.t_hts, t => t.htbm, p => p.htbm, (t, p) => new { p.khbm }) .Join(db.t_khs, t => t.khbm, p => p.khbm, (t, p) => p.khmc).FirstOrDefault(); htfz.khmc = khmc; } return htfz; } public dto_gzb getgzbbytm(string tm) { //throw new NotImplementedException(); int itm = 0; if (!int.TryParse(tm, out itm)) { return null; } string stm = itm.ToString("0000000000"); using (var db = new DbEntities()) { if (stm.StartsWith("1")) { return db.t_ttgzbs.Where(t => t.tm == itm).Join(db.t_hts, t => t.htbm, p => p.htbm, (t, p) => new { gzb = t, p.khbm }).Join(db.t_khs, t => t.khbm, p => p.khbm, (t, p) => new { gzb = t.gzb, p.khmc }) .Select(t => new dto_gzb { tmztz = t.gzb.tmztz, hyh = t.gzb.hyh, xb = t.gzb.xb, tjrq = t.gzb.tjrq, sfzh = t.gzb.sfzh, xm = t.gzb.xm, nl = t.gzb.nl, csrq = t.gzb.csrq, lx = 2, ygdh = t.gzb.tel, ygbh = t.gzb.ygh, ygbm = t.gzb.ssbm, dwmc = t.khmc, hyzk = t.gzb.hyzk, tm = t.gzb.tm, khmc = t.khmc, fddm = t.gzb.fddm }).FirstOrDefault(); } else { return db.t_grgzbs.Where(t => t.tm == itm).Select(t => new dto_gzb { tmztz = t.tmztz, tcbm = t.tcbm, tm = t.tm, hyzk = t.hyzk, hyh = t.hyh, xb = t.xb, tjrq = t.tjrq, sfzh = t.sfzh, ygbm = t.khlx == 1 ? "V" : "", xm = t.xm, nl = t.nl, csrq = t.csrq, lx = 1, ygdh = t.dh, fddm = t.fddm }).FirstOrDefault(); } } } public List getdjxmbytm(int tm) { //throw new NotImplementedException(); using (var db = new DbEntities()) { var ttgzb = db.t_ttgzbs.Where(t => t.tm == tm).FirstOrDefault(); if (ttgzb != null && ttgzb.tmztz == 0) { var xms = db.t_htxmbs.Where(t => t.htfzbm == ttgzb.htfzbm).Join(db.t_zhxms.Where(p => p.jclb != 2), t => t.zhbm, p => p.zhbm, (t, p) => new dto_dxjm { tm = ttgzb.tm, zhbm = t.zhbm, zhmc = p.zhmc, jclb = p.jclb, // ztz = ttgzb.ztz, cqxm = p.cqxm == 0 ? "餐后检查项目" : "餐前检查项目", quyu = p.quyu, wlks = p.wlks }); if (xms.Any()) { return xms.ToList(); } else { return null; } } var djxms = db.t_tempdjxms.Where(t => t.tm == tm).Join(db.t_zhxms.Where(p => p.jclb != 2), t => t.zhbm, p => p.zhbm, (t, p) => new dto_dxjm { tm = t.tm, zhbm = t.zhbm, zhmc = p.zhmc, jclb = p.jclb, ztz = t.ztz, cqxm = p.cqxm == 0 ? "餐后检查项目" : "餐前检查项目", quyu = p.quyu, wlks = p.wlks }); if (djxms.Any()) { return djxms.ToList(); } else { return null; } } } public List getdjxmbytm2(int tm) { //throw new NotImplementedException(); using (var db = new DbEntities()) { int[] aa = new int[] { 0, 1, 3 }; var ttgzb = db.t_ttgzbs.Where(t => t.tm == tm).FirstOrDefault(); if (ttgzb != null) { var xms = db.t_tempdjxms.Where(t => t.tm == tm && aa.Contains(t.ztz)).Join(db.t_zhxms.Where(p => p.jclb != 2), t => t.zhbm, p => p.zhbm, (t, p) => new dto_dxjm { tm = ttgzb.tm, zhbm = t.zhbm, zhmc = p.zhmc, jclb = p.jclb, // ztz = ttgzb.ztz, cqxm = p.cqxm == 0 ? "餐后检查项目" : "餐前检查项目", quyu = p.quyu, wlks = p.wlks }); if (xms.Any()) { return xms.ToList(); } else { return null; } } var djxms = db.t_tempdjxms.Where(t => t.tm == tm && aa.Contains(t.ztz)).Join(db.t_zhxms.Where(p => p.jclb != 2), t => t.zhbm, p => p.zhbm, (t, p) => new dto_dxjm { tm = t.tm, zhbm = t.zhbm, zhmc = p.zhmc, jclb = p.jclb, ztz = t.ztz, cqxm = p.cqxm == 0 ? "餐后检查项目" : "餐前检查项目", quyu = p.quyu, wlks = p.wlks }); if (djxms.Any()) { return djxms.ToList(); } else { return null; } } } public List findgrbd(string text) { //throw new NotImplementedException(); using (var db = new DbEntities()) { var rdb = db.t_grgzbs.Where(t => t.tmztz == 2); if (text.Trim() != null) { rdb = rdb.Where(t => t.xm.Contains(text)); } if (rdb.Any()) { return rdb.Select(t => new dto_gzb { tmztz = t.tmztz, tcbm = t.tcbm, tm = t.tm, hyzk = t.hyzk, hyh = t.hyh, xb = t.xb, tjrq = t.tjrq, sfzh = t.sfzh, xm = t.xm, nl = t.nl, csrq = t.csrq, lx = 1, ygdh = t.dh }).ToList(); } else { return null; } } } public List findttbd(string text) { //throw new NotImplementedException(); using (var db = new DbEntities()) { var rdb = db.t_ttgzbs.Where(t => t.tmztz == 2); if (text.Trim() != null) { rdb = rdb.Where(t => t.xm.Contains(text)); } if (rdb.Any()) { return rdb.Select(t => new dto_gzb { tmztz = t.tmztz, tcbm = t.htfzbm, tm = t.tm, hyzk = t.hyzk, hyh = t.hyh, xb = t.xb, tjrq = t.tjrq, sfzh = t.sfzh, xm = t.xm, nl = t.nl, csrq = t.csrq, lx = 1, ygdh = t.tel }).ToList(); } else { return null; } } } public List getXuYaoShouFeidcry(short fddm) { throw new NotImplementedException(); } public OperationResult gettm(int tm, int xb, int zhbm) { //throw new NotImplementedException(); using (var db = new DbEntities()) { OperationResult or = new OperationResult(); var gzb = getgzbbytm(tm.ToString()); ///新收费信息 if (xb == 0) { var tran = db.CreateTransaction(); try { var s = db.t_tempdjxms.Where(t => t.tm == tm && t.ztz == 0) .Join(db.t_zhxms.Where(t => t.jclb == 1), t => t.zhbm, p => p.zhbm, (t, p) => new { t.tm, t.zhbm, p.zhmc, p.jydl, cxsl = p.dytmsl, p.color, p.wsbj }).ToList(); var ttgzb = db.t_ttgzbs.FirstOrDefault(t => t.tm == tm); if (ttgzb != null && ttgzb.tmztz == 0) { s = db.t_htxmbs.Where(t => t.htfzbm == ttgzb.htfzbm).Join(db.t_zhxms.Where(t => t.jclb == 1), t => t.zhbm, p => p.zhbm, (t, p) => new { tm = ttgzb.tm, t.zhbm, p.zhmc, p.jydl, cxsl = p.dytmsl, p.color, p.wsbj }).ToList(); } var y = db.jy_sqds.Where(t => t.tm == tm).Join(db.jy_sqd_mxs, t => t.jytm, p => p.jytm, (t, p) => new { p.zhxmbm, p.jytm }).ToList(); var notin = s.Where(p => !y.Where(t => t.zhxmbm == p.zhbm).Any()).ToList(); var inxm = s.Where(p => y.Where(t => t.zhxmbm == p.zhbm).Any()).ToList(); var inxms = inxm.Join(y, t => t.zhbm, p => p.zhxmbm, (t, p) => new { t.zhbm, t.zhmc, t.tm, t.jydl, p.jytm, t.cxsl, t.color }); List tms = new List(); int sqdi = 0; var jytm = db.jy_sqds.Where(jy => jy.tm == tm && jy.jytm.StartsWith(tm.ToString("0000000000"))) .OrderByDescending(jy => jy.jytm).Select(jy => jy.jytm).FirstOrDefault(); if (jytm == null) { //sqd.jytm = tm.ToString("000000000") + "01"; sqdi = 1; } else { //sqd.jytm = tm.ToString("000000000") + (int.Parse(jytm.Replace(tm.ToString("000000000"), "")) + 1).ToString("00"); sqdi = int.Parse(jytm.Replace(tm.ToString("0000000000"), "")) + 1; } notin.GroupBy(t => new { t.jydl, t.color, t.wsbj }).ToList().ForEach(t => { jy_sqd sqd = new jy_sqd(); sqd.tm = tm; sqd.xm = gzb.xm; sqd.xb = gzb.v_xb; sqd.state = 0; sqd.cxsj = new DateTime(1900, 1, 1); sqd.shsj = new DateTime(1900, 1, 1); sqd.csrq = gzb.csrq; sqd.nl = gzb.nl; sqd.jytm = tm.ToString("0000000000") + sqdi.ToString("00"); dto_tmdy tmdy = new dto_tmdy(); tmdy.jytm = sqd.jytm; db.jy_sqds.Insert(sqd); //t.Key.zhbm //瑞美LIS插入客户信息表 lis_reqmain lismain = new lis_reqmain(); lismain.testno = tm.ToString("0000000000") + sqdi.ToString("00"); lismain.deptno = "检验科"; //lismain.pattype = ""; lismain.reqdatetime = DateTime.Now; if (gzb.fddm == 2) { lismain.reqdoctno = "trdwj"; } else { lismain.reqdoctno = "trlxz"; } lismain.patno = tm.ToString(); lismain.patname = gzb.xm; lismain.sex = gzb.v_xb; lismain.birthday = gzb.csrq; lismain.address = ""; lismain.telephone = gzb.ygdh; lismain.status = "1"; lismain.recievedatetime = DateTime.Now; //lismain.yjxh = 0; //lismain.hysqd_xh = 0; db.lis_reqmains.Insert(lismain); int i = 0; tmdy.jymx = ""; tmdy.color = t.Key.color; int sl = 0; notin.Where(p => p.jydl == t.Key.jydl).ToList().ForEach(o => { if (sl < o.cxsl) sl = o.cxsl; jy_sqd_mx xm = new jy_sqd_mx { jytm = sqd.jytm, jyxh = ++i, zhxmbm = o.zhbm, zhxmmc = o.zhmc }; db.jy_sqd_mxs.Insert(xm); //瑞美LIS插入检验项目表 //if (gzb.fddm == 2) //{ lis_reqitems lisitem = new lis_reqitems(); lisitem.testno = sqd.jytm; lisitem.seqno = xm.jyxh; lisitem.itemno = o.zhbm.ToString(); lisitem.itemname = o.zhmc; //lisitem.qty= lisitem.price = 20; lisitem.isaccept = 0; lisitem.zk = 100; lisitem.yj = 100; db.lis_reqitemss.Insert(lisitem); //} tmdy.jymx += (tmdy.jymx.Length == 0 ? "" : "\r\n") + o.zhmc; }); sqdi++; for (int z = 0; z < sl; z++) tms.Add(tmdy); }); tran.Commit(); if (ttgzb != null && ttgzb.tmztz == 0) { inxms.GroupBy(t => new { t.jytm, t.color }).ToList().ForEach(t => { //var zz = db.jy_sqds.Where(jy => jy.tm == tm && jy.jytm.StartsWith(tm.ToString("0000000000"))) //.OrderByDescending(jy => jy.jytm).Select(jy => jy.jytm); dto_tmdy tmdy = new dto_tmdy(); tmdy.jytm = t.Key.jytm; tmdy.jymx = ""; tmdy.color = t.Key.color; int sl = 0; inxms.Where(p => p.jytm == t.Key.jytm).ToList().ForEach(o => { if (sl < o.cxsl) sl = o.cxsl; tmdy.jymx += (tmdy.jymx.Length == 0 ? "" : "\r\n") + o.zhmc; }); for (int z = 0; z < sl; z++) tms.Add(tmdy); }); } var qt = db.t_tempdjxms.Where(t => t.ztz == 0 && t.tm == tm).Join(db.t_zhxms.Where(t => t.jclb != 1 && t.dytmsl > 0), t => t.zhbm, p => p.zhbm, (t, p) => new { t.tm, p.zhmc, p.dytmsl,p.color }); if (ttgzb != null && ttgzb.tmztz == 0) { qt = db.t_htxmbs.Where(t => t.htfzbm == ttgzb.htfzbm).Join(db.t_zhxms.Where(t => t.jclb != 1 && t.dytmsl > 0), t => t.zhbm, p => p.zhbm, (t, p) => new { tm = ttgzb.tm, p.zhmc, p.dytmsl,p.color }); } if (qt.Any()) { qt.ToList().ForEach(t => { dto_tmdy tmdy = new dto_tmdy(); tmdy.jytm = tm.ToString("0000000000"); tmdy.jymx = t.zhmc; tmdy.color = t.color; for (int z = 0; z < t.dytmsl; z++) tms.Add(tmdy); }); } or.State = 1; or.Message = "成功!"; or.Tag = Newtonsoft.Json.JsonConvert.SerializeObject(tms); return or; } catch (Exception ex) { tran.Rollback(); or.State = 0; or.Message = ex.Message; return or; } } else { //var s = db.t_tempdjxms.Where(t => t.tm == tm && t.ztz == 0); var s = db.t_tempdjxms.Where(t => t.tm == tm); if (zhbm != 0 && zhbm!=8888) { s = s.Where(t => t.zhbm == zhbm); } var x = s.Join(db.t_zhxms.Where(t => t.jclb == 1), t => t.zhbm, p => p.zhbm, (t, p) => new { t.tm, t.zhbm, p.zhmc, p.jydl, p.dytmsl, p.color }).ToList(); var y = db.jy_sqds.Where(t => t.tm == tm).Join(db.jy_sqd_mxs, t => t.jytm, p => p.jytm, (t, p) => new { t.jytm, p.zhxmbm }).ToList(); var jymx = x.Join(y, t => t.zhbm, p => p.zhxmbm, (t, p) => new { p.jytm, zhmc = t.zhmc, t.dytmsl, t.color }).ToList(); List tms = new List(); jymx.GroupBy(t => new { t.jytm, t.color }).ToList().ForEach(t => { dto_tmdy tmdy = new dto_tmdy(); tmdy.jytm = t.Key.jytm; tmdy.color = t.Key.color; tmdy.jymx = ""; int sl = 0; jymx.Where(o => o.jytm == t.Key.jytm).ToList().ForEach(o => { //if (sl < o.dytmsl) sl = o.dytmsl; tmdy.jymx += (tmdy.jymx.Length == 0 ? "" : "\r\n") + o.zhmc; }); for (int z = 0; z < sl; z++) tms.Add(tmdy); var lisreqmain = db.lis_reqmains.Where(l => l.testno == t.Key.jytm).ToList(); if (lisreqmain.Count == 0) { var jysqds = db.jy_sqds.Where(jj => jj.jytm == t.Key.jytm).ToList(); //瑞美LIS插入客户信息表 lis_reqmain lismain = new lis_reqmain(); lismain.testno = t.Key.jytm; lismain.deptno = "检验科"; //lismain.pattype = ""; lismain.reqdatetime = DateTime.Now; if (gzb.fddm == 2) { lismain.reqdoctno = "trdwj"; } else { lismain.reqdoctno = "trlxz"; } lismain.patno = tm.ToString(); lismain.patname = gzb.xm; lismain.sex = gzb.v_xb; lismain.birthday = gzb.csrq; lismain.address = ""; lismain.telephone = gzb.ygdh; lismain.status = "1"; lismain.recievedatetime = DateTime.Now; //lismain.yjxh = 0; //lismain.hysqd_xh = 0; db.lis_reqmains.Insert(lismain); //} var lisreqitem = db.lis_reqitemss.Where(ii => ii.testno == t.Key.jytm).ToList(); if (lisreqitem.Count == 0) { db.jy_sqd_mxs.Where(jjj => jjj.jytm == t.Key.jytm).ToList().ForEach(jjj => { //瑞美LIS插入检验项目表 lis_reqitems lisitem = new lis_reqitems(); lisitem.testno = jjj.jytm; lisitem.seqno = jjj.jyxh; lisitem.itemno = jjj.zhxmbm.ToString(); lisitem.itemname = jjj.zhxmmc; //lisitem.qty= lisitem.price = 20; lisitem.isaccept = 0; lisitem.zk = 100; lisitem.yj = 100; db.lis_reqitemss.Insert(lisitem); }); } } }); var qt = db.t_tempdjxms.Where(t => t.tm == tm); if (zhbm != 0 && zhbm != 8888) { qt = qt.Where(t => t.zhbm == zhbm); } var qt1 = qt.Join(db.t_zhxms.Where(t => t.jclb != 1 && t.dytmsl > 0), t => t.zhbm, p => p.zhbm, (t, p) => new { t.tm, p.zhmc, p.dytmsl,p.color }); if (qt1.Any()) { qt1.ToList().ForEach(t => { dto_tmdy tmdy = new dto_tmdy(); tmdy.jytm = tm.ToString("0000000000"); tmdy.jymx = t.zhmc; tmdy.color = t.color; for (int z = 0; z < t.dytmsl; z++) { tms.Add(tmdy); } }); } or.State = 1; or.Message = "成功!"; or.Tag = Newtonsoft.Json.JsonConvert.SerializeObject(tms); return or; } } } public OperationResult gettm2(int tm, int xb, int zhbm) { //throw new NotImplementedException(); using (var db = new DbEntities()) { OperationResult or = new OperationResult(); var gzb = getgzbbytm(tm.ToString()); ///新收费信息 if (xb == 0) { var tran = db.CreateTransaction(); try { var s = db.t_tempdjxms.Where(t => t.tm == tm && t.ztz == 0) .Join(db.t_zhxms.Where(t => t.jclb == 1), t => t.zhbm, p => p.zhbm, (t, p) => new { t.tm, t.zhbm, p.zhmc, p.jydl, cxsl = p.dytmsl, p.color, p.wsbj }).ToList(); var ttgzb = db.t_ttgzbs.FirstOrDefault(t => t.tm == tm); if (ttgzb != null && ttgzb.tmztz == 0) { s = db.t_htxmbs.Where(t => t.htfzbm == ttgzb.htfzbm).Join(db.t_zhxms.Where(t => t.jclb == 1), t => t.zhbm, p => p.zhbm, (t, p) => new { tm = ttgzb.tm, t.zhbm, p.zhmc, p.jydl, cxsl = p.dytmsl, p.color, p.wsbj }).ToList(); } var y = db.jy_sqds.Where(t => t.tm == tm).Join(db.jy_sqd_mxs, t => t.jytm, p => p.jytm, (t, p) => new { p.zhxmbm, p.jytm }).ToList(); var notin = s.Where(p => !y.Where(t => t.zhxmbm == p.zhbm).Any()).ToList(); var inxm = s.Where(p => y.Where(t => t.zhxmbm == p.zhbm).Any()).ToList(); var inxms = inxm.Join(y, t => t.zhbm, p => p.zhxmbm, (t, p) => new { t.zhbm, t.zhmc, t.tm, t.jydl, p.jytm, t.cxsl, t.color }); List tms = new List(); int sqdi = 0; var jytm = db.jy_sqds.Where(jy => jy.tm == tm && jy.jytm.StartsWith(tm.ToString("0000000000"))) .OrderByDescending(jy => jy.jytm).Select(jy => jy.jytm).FirstOrDefault(); if (jytm == null) { //sqd.jytm = tm.ToString("000000000") + "01"; sqdi = 1; } else { //sqd.jytm = tm.ToString("000000000") + (int.Parse(jytm.Replace(tm.ToString("000000000"), "")) + 1).ToString("00"); sqdi = int.Parse(jytm.Replace(tm.ToString("0000000000"), "")) + 1; } notin.GroupBy(t => new { t.jydl, t.color, t.wsbj }).ToList().ForEach(t => { jy_sqd sqd = new jy_sqd(); sqd.tm = tm; sqd.xm = gzb.xm; sqd.xb = gzb.v_xb; sqd.state = 0; sqd.cxsj = new DateTime(1900, 1, 1); sqd.shsj = new DateTime(1900, 1, 1); sqd.csrq = gzb.csrq; sqd.nl = gzb.nl; sqd.jytm = tm.ToString("0000000000") + sqdi.ToString("00"); dto_tmdy tmdy = new dto_tmdy(); tmdy.jytm = sqd.jytm; db.jy_sqds.Insert(sqd); //t.Key.zhbm //if (gzb.fddm == 2) //{ //瑞美LIS插入客户信息表 lis_reqmain lismain = new lis_reqmain(); lismain.testno = tm.ToString("0000000000") + sqdi.ToString("00"); lismain.deptno = "检验科"; //lismain.pattype = ""; lismain.reqdatetime = DateTime.Now; if (gzb.fddm == 2) { lismain.reqdoctno = "trdwj"; } else { lismain.reqdoctno = "trlxz"; } lismain.patno = tm.ToString(); lismain.patname = gzb.xm; lismain.sex = gzb.v_xb; lismain.birthday = gzb.csrq; lismain.address = ""; lismain.telephone = gzb.ygdh; lismain.status = "1"; lismain.recievedatetime = DateTime.Now; //lismain.yjxh = 0; //lismain.hysqd_xh = 0; db.lis_reqmains.Insert(lismain); //} int i = 0; tmdy.jymx = ""; tmdy.color = t.Key.color; int sl = 0; notin.Where(p => p.jydl == t.Key.jydl).ToList().ForEach(o => { if (sl < o.cxsl) sl = o.cxsl; jy_sqd_mx xm = new jy_sqd_mx { jytm = sqd.jytm, jyxh = ++i, zhxmbm = o.zhbm, zhxmmc = o.zhmc }; db.jy_sqd_mxs.Insert(xm); //瑞美LIS插入检验项目表 //if (gzb.fddm == 2) //{ lis_reqitems lisitem = new lis_reqitems(); lisitem.testno = sqd.jytm; lisitem.seqno = xm.jyxh; lisitem.itemno = o.zhbm.ToString(); lisitem.itemname = o.zhmc; //lisitem.qty= lisitem.price = 20; lisitem.isaccept = 0; lisitem.zk = 100; lisitem.yj = 100; db.lis_reqitemss.Insert(lisitem); //} tmdy.jymx += (tmdy.jymx.Length == 0 ? "" : "\r\n") + o.zhmc; }); sqdi++; for (int z = 0; z < sl; z++) tms.Add(tmdy); }); tran.Commit(); if (ttgzb != null && ttgzb.tmztz == 0) { inxms.GroupBy(t => new { t.jytm, t.color }).ToList().ForEach(t => { //var zz = db.jy_sqds.Where(jy => jy.tm == tm && jy.jytm.StartsWith(tm.ToString("0000000000"))) //.OrderByDescending(jy => jy.jytm).Select(jy => jy.jytm); dto_tmdy tmdy = new dto_tmdy(); tmdy.jytm = t.Key.jytm; tmdy.jymx = ""; tmdy.color = t.Key.color; int sl = 0; inxms.Where(p => p.jytm == t.Key.jytm).ToList().ForEach(o => { if (sl < o.cxsl) sl = o.cxsl; tmdy.jymx += (tmdy.jymx.Length == 0 ? "" : "\r\n") + o.zhmc; }); for (int z = 0; z < sl; z++) tms.Add(tmdy); }); } var qt = db.t_tempdjxms.Where(t => t.ztz == 0 && t.tm == tm).Join(db.t_zhxms.Where(t => t.jclb != 1 && t.dytmsl > 0), t => t.zhbm, p => p.zhbm, (t, p) => new { t.tm, p.zhmc, p.dytmsl,p.color }); if (ttgzb != null && ttgzb.tmztz == 0) { qt = db.t_htxmbs.Where(t => t.htfzbm == ttgzb.htfzbm).Join(db.t_zhxms.Where(t => t.jclb != 1 && t.dytmsl > 0), t => t.zhbm, p => p.zhbm, (t, p) => new { tm = ttgzb.tm, p.zhmc, p.dytmsl,p.color }); } if (qt.Any()) { qt.ToList().ForEach(t => { dto_tmdy tmdy = new dto_tmdy(); tmdy.jytm = tm.ToString("0000000000"); tmdy.jymx = t.zhmc; tmdy.color = t.color; for (int z = 0; z < t.dytmsl; z++) tms.Add(tmdy); }); } or.State = 1; or.Message = "成功!"; or.Tag = Newtonsoft.Json.JsonConvert.SerializeObject(tms); return or; } catch (Exception ex) { tran.Rollback(); or.State = 0; or.Message = ex.Message; return or; } } else { int[] aa = new int[] { 0, 1, 3 }; //var s = db.t_tempdjxms.Where(t => t.tm == tm && t.ztz == 0); var s = db.t_tempdjxms.Where(t => t.tm == tm && aa.Contains(t.ztz)); var x = s.Join(db.t_zhxms.Where(t => t.jclb == 1), t => t.zhbm, p => p.zhbm, (t, p) => new { t.tm, t.zhbm, p.zhmc, p.jydl, p.dytmsl, p.color }).ToList(); var y = db.jy_sqds.Where(t => t.tm == tm).Join(db.jy_sqd_mxs, t => t.jytm, p => p.jytm, (t, p) => new { t.jytm, p.zhxmbm }).ToList(); var jymx = x.Join(y, t => t.zhbm, p => p.zhxmbm, (t, p) => new { p.jytm, zhmc = t.zhmc, t.dytmsl, t.color }).ToList(); List tms = new List(); jymx.GroupBy(t => new { t.jytm, t.color }).ToList().ForEach(t => { dto_tmdy tmdy = new dto_tmdy(); tmdy.jytm = t.Key.jytm; tmdy.color = t.Key.color; tmdy.jymx = ""; int sl = 0; jymx.Where(o => o.jytm == t.Key.jytm).ToList().ForEach(o => { //if (sl < o.dytmsl) sl = o.dytmsl; tmdy.jymx += (tmdy.jymx.Length == 0 ? "" : "\r\n") + o.zhmc; }); for (int z = 0; z < sl; z++) tms.Add(tmdy); //if (gzb.fddm == 2) //{ var lisreqmain = db.lis_reqmains.Where(l => l.testno == t.Key.jytm).ToList(); if (lisreqmain.Count == 0) { var jysqds = db.jy_sqds.Where(jj => jj.jytm == t.Key.jytm).ToList(); //瑞美LIS插入客户信息表 lis_reqmain lismain = new lis_reqmain(); lismain.testno = t.Key.jytm; lismain.deptno = "检验科"; //lismain.pattype = ""; lismain.reqdatetime = DateTime.Now; if (gzb.fddm == 2) { lismain.reqdoctno = "trdwj"; } else { lismain.reqdoctno = "trlxz"; } lismain.patno = tm.ToString(); lismain.patname = gzb.xm; lismain.sex = gzb.v_xb; lismain.birthday = gzb.csrq; lismain.address = ""; lismain.telephone = gzb.ygdh; lismain.status = "1"; lismain.recievedatetime = DateTime.Now; //lismain.yjxh = 0; //lismain.hysqd_xh = 0; db.lis_reqmains.Insert(lismain); } var lisreqitem = db.lis_reqitemss.Where(ii => ii.testno == t.Key.jytm).ToList(); if (lisreqitem.Count == 0) { db.jy_sqd_mxs.Where(jjj => jjj.jytm == t.Key.jytm).ToList().ForEach(jjj => { //瑞美LIS插入检验项目表 lis_reqitems lisitem = new lis_reqitems(); lisitem.testno = jjj.jytm; lisitem.seqno = jjj.jyxh; lisitem.itemno = jjj.zhxmbm.ToString(); lisitem.itemname = jjj.zhxmmc; //lisitem.qty= lisitem.price = 20; lisitem.isaccept = 0; lisitem.zk = 100; lisitem.yj = 100; db.lis_reqitemss.Insert(lisitem); }); } //} }); var qt = db.t_tempdjxms.Where(t => t.tm == tm && aa.Contains(t.ztz)); var qt1 = qt.Join(db.t_zhxms.Where(t => t.jclb != 1 && t.dytmsl > 0), t => t.zhbm, p => p.zhbm, (t, p) => new { t.tm, p.zhmc, p.dytmsl,p.color }); if (qt1.Any()) { qt1.ToList().ForEach(t => { dto_tmdy tmdy = new dto_tmdy(); tmdy.jytm = tm.ToString("0000000000"); tmdy.jymx = t.zhmc; tmdy.color = t.color; for (int z = 0; z < t.dytmsl; z++) { tms.Add(tmdy); } }); } or.State = 1; or.Message = "成功!"; or.Tag = Newtonsoft.Json.JsonConvert.SerializeObject(tms); return or; } } } public bool checktmprint(string tm, int zhbm) { // throw new NotImplementedException(); using (var db = new DbEntities()) { int itm = 0; int.TryParse(tm, out itm); var v = db.t_tempdjxms.Where(t => t.tm == itm && t.zhbm == zhbm).Join(db.t_zhxms, t => t.zhbm, p => p.zhbm, (t, p) => new { t.ztz, p.jclb, p.dytmsl }).FirstOrDefault(); if (v == null) { return false; } else { //if (v.ztz == 0 && v.dytmsl > 0) if (v.dytmsl > 0) { return true; } else { return false; } } } } public List getycztm(int tm) { //throw new NotImplementedException(); using (var db = new DbEntities()) { var ndys = new List(); db.t_tempdjxms.Where(t => t.tm == tm).Join(db.t_zhxms.Where(t => t.jclb != 1 && t.dytmsl > 0), t => t.zhbm, p => p.zhbm, (t, p) => new { t.tm, p.zhmc }).ToList().ForEach( t => { ndys.Add(new dto_tmdy { jytm = t.tm.ToString("0000000000"), jymx = t.zhmc }); } ); return ndys; } } public List getycztm2(int tm) { //throw new NotImplementedException(); using (var db = new DbEntities()) { var ndys = new List(); db.t_tempdjxms.Where(t => t.tm == tm && t.ztz == 4).Join(db.t_zhxms.Where(t => t.dytmsl > 0), t => t.zhbm, p => p.zhbm, (t, p) => new { t.tm, p.zhmc }).ToList().ForEach( t => { ndys.Add(new dto_tmdy { jytm = t.tm.ToString("0000000000"), jymx = t.zhmc }); } ); return ndys; } } public T_drxpjl getXpjl(int xh) { using (var db = new DbEntities()) { var data = from a in db.T_drxpjls where a.xh == xh select a; if (data.Any()) { return data.First(); } else { return null; } } } /// /// 根据体检日期获取当日的收费信息 /// /// /// public List GetDrSfmx(short fddm, DateTime dt) { if (dt == null) { return null; } DateTime dt1 = DateTime.Parse(dt.ToString("yyyy-MM-dd") + " 00:00:00"); DateTime dt2 = DateTime.Parse(dt.ToString("yyyy-MM-dd") + " 23:59:59"); using (DbEntities db = new DbEntities()) { var data = from a in db.t_sfmxbs where a.fddm == fddm && a.tjrq > dt1 && a.tjrq < dt2 select a; if (data.Any()) { return data.ToList(); } else { return null; } } } } }