| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 |
- package com.zhcs.dt.controller.system.head;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import javax.annotation.Resource;
- import org.apache.shiro.session.Session;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.servlet.ModelAndView;
- import com.zhcs.dt.controller.base.BaseController;
- import com.zhcs.dt.entity.system.Role;
- import com.zhcs.dt.service.system.appuser.AppuserManager;
- //import com.zhcs.dt.service.system.fhsms.FhsmsManager;
- import com.zhcs.dt.service.system.role.RoleManager;
- import com.zhcs.dt.service.system.user.UserManager;
- import com.zhcs.dt.service.system.userphoto.UserPhotoManager;
- import com.zhcs.dt.util.AppUtil;
- import com.zhcs.dt.util.Const;
- import com.zhcs.dt.util.Jurisdiction;
- import com.zhcs.dt.util.PageData;
- import com.zhcs.dt.util.SmsUtil;
- import com.zhcs.dt.util.Tools;
- import com.zhcs.dt.util.Watermark;
- //import com.zhcs.dt.util.mail.SimpleMailSender;
- /**
- * 类名称:HeadController
- * 创建人:FH 313596790Q
- * 修改时间:2018年2月4日
- * @version
- */
- @Controller
- @RequestMapping(value="/head")
- public class HeadController extends BaseController {
-
- @Resource(name="userService")
- private UserManager userService;
- @Resource(name="appuserService")
- private AppuserManager appuserService;
- // @Resource(name="fhsmsService")
- // private FhsmsManager fhsmsService;
- @Resource(name="userphotoService")
- private UserPhotoManager userphotoService;
- @Resource(name="roleService")
- private RoleManager roleService;
-
- /**去编辑头像页面
- * @return
- * @throws Exception
- */
- @RequestMapping(value="/editPhoto")
- public ModelAndView editPhoto() throws Exception{
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- mv.setViewName("system/userphoto/userphoto_edit");
- mv.addObject("pd", pd);
- return mv;
- }
-
- /**获取基本信息
- * @return
- */
- @RequestMapping(value="/getList")
- @ResponseBody
- public Object getList() {
- PageData pd = new PageData();
- Map<String,Object> map = new HashMap<String,Object>();
- try {
- pd = this.getPageData();
- List<PageData> pdList = new ArrayList<PageData>();
- Session session = Jurisdiction.getSession();
- PageData pds = new PageData();
- pds = (PageData)session.getAttribute(Const.SESSION_userpds);
- if(null == pds){
- pd.put(Const.SESSION_USERNAME, Jurisdiction.getUsername());//当前登录者用户名
- pds = userService.findByUsername(pd);
- session.setAttribute(Const.SESSION_userpds, pds);
- }
- pdList.add(pds);
- map.put("list", pdList);
- PageData pdPhoto = userphotoService.findById(pds);
- map.put("userPhoto", null == pdPhoto?"static/ace/avatars/user.jpg":pdPhoto.getString("PHOTO2"));//用户头像
- // map.put("fhsmsCount", fhsmsService.findFhsmsCount(Jurisdiction.getUsername()).get("fhsmsCount").toString());//站内信未读总数
- String strWEBSOCKET = Tools.readTxtFile(Const.WEBSOCKET);//读取WEBSOCKET配置
- if(null != strWEBSOCKET && !"".equals(strWEBSOCKET)){
- String strIW[] = strWEBSOCKET.split(",fh,");
- if(strIW.length == 7){
- map.put("wimadress", strIW[0]+":"+strIW[1]); //即时聊天服务器IP和端口
- map.put("oladress", strIW[2]+":"+strIW[3]); //在线管理和站内信服务器IP和端口
- map.put("FHsmsSound", strIW[4]); //站内信提示音效配置
- }
- }
- Object RNUMBERS = session.getAttribute(Const.SESSION_RNUMBERS);
- if(null == RNUMBERS){
- session.setAttribute(Const.SESSION_RNUMBERS, getRnumbers()); //把当前用户的角色编码放入session
- }
- } catch (Exception e) {
- logger.error(e.toString(), e);
- } finally {
- logAfter(logger);
- }
- return AppUtil.returnObject(pd, map);
- }
-
- /**判断当前用户角色编码符合过滤条件(用于新任务消息通知)
- * @return
- * @throws Exception
- */
- @RequestMapping(value="/isNowRole")
- @ResponseBody
- public Object isNowRole() throws Exception{
- PageData pd = new PageData();
- pd = this.getPageData();
- Map<String,Object> map = new HashMap<String,Object>();
- if(Jurisdiction.getRnumbers().indexOf(pd.getString("RNUMBER"))!=-1){
- map.put("msg", "yes");
- }else{
- map.put("msg", "no");
- }
- return AppUtil.returnObject(pd, map);
- }
-
- /**通过角色ID数组获取角色列表拼接角色编码
- * @return
- * @throws Exception
- */
- public String getRnumbers() throws Exception{
- PageData userpd = new PageData();
- userpd.put(Const.SESSION_USERNAME, Jurisdiction.getUsername());
- userpd = userService.findByUsername(userpd); //通过用户名获取用户信息
- String ZROLE_ID = userpd.get("ROLE_ID").toString()+",fh,"+userpd.getString("ROLE_IDS");
- String arryROLE_ID[] = ZROLE_ID.split(",fh,");
- List<Role> rlist = roleService.getRoleByArryROLE_ID(arryROLE_ID);
- StringBuffer RNUMBERS = new StringBuffer();
- RNUMBERS.append("(");
- for(Role role:rlist){
- RNUMBERS.append("'"+role.getRNUMBER()+"'");
- }
- RNUMBERS.append(")");
- return RNUMBERS.toString();
- }
-
- /**保存用户皮肤
- * @return
- * @throws Exception
- */
- @RequestMapping(value="/saveSkin")
- @ResponseBody
- public Object saveSkin() throws Exception{
- PageData pd = new PageData();
- pd = this.getPageData();
- pd.put(Const.SESSION_USERNAME, Jurisdiction.getUsername());//当前登录者用户名
- userService.saveSkin(pd);
- Session session = Jurisdiction.getSession();
- session.setAttribute(Const.SKIN, pd.getString("SKIN"));
- Map<String,Object> map = new HashMap<String,Object>();
- map.put("pd", pd);
- return AppUtil.returnObject(pd, map);
- }
- /* *//**获取站内信未读总数
- * @return
- *//*
- @RequestMapping(value="/getFhsmsCount")
- @ResponseBody
- public Object getFhsmsCount() {
- PageData pd = new PageData();
- Map<String,Object> map = new HashMap<String,Object>();
- try {
- map.put("fhsmsCount", fhsmsService.findFhsmsCount(Jurisdiction.getUsername()).get("fhsmsCount").toString());//站内信未读总数
- } catch (Exception e) {
- logger.error(e.toString(), e);
- } finally {
- logAfter(logger);
- }
- return AppUtil.returnObject(pd, map);
- }*/
-
- /**去发送邮箱页面
- * @return
- * @throws Exception
- */
- @RequestMapping(value="/editEmail")
- public ModelAndView editEmail() throws Exception{
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- mv.setViewName("system/head/edit_email");
- mv.addObject("pd", pd);
- return mv;
- }
-
- /**去发送短信页面
- * @return
- * @throws Exception
- */
- @RequestMapping(value="/goSendSms")
- public ModelAndView goSendSms() throws Exception{
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- mv.setViewName("system/head/send_sms");
- mv.addObject("pd", pd);
- return mv;
- }
-
-
- /**发送短信
- * @return
- */
- @RequestMapping(value="/sendSms")
- @ResponseBody
- public Object sendSms(){
- PageData pd = new PageData();
- pd = this.getPageData();
- Map<String,Object> map = new HashMap<String,Object>();
- String msg = "ok"; //发送状态
- int count = 0; //统计发送成功条数
- int zcount = 0; //理论条数
- List<PageData> pdList = new ArrayList<PageData>();
- String PHONEs = pd.getString("PHONE"); //对方邮箱
- String CONTENT = pd.getString("CONTENT"); //内容
- String isAll = pd.getString("isAll"); //是否发送给全体成员 yes or no
- String TYPE = pd.getString("TYPE"); //类型 1:短信接口1 2:短信接口2
- String fmsg = pd.getString("fmsg"); //判断是系统用户还是会员 "appuser"为会员用户
- if("yes".endsWith(isAll)){
- try {
- List<PageData> userList = new ArrayList<PageData>();
- userList = "appuser".equals(fmsg) ? appuserService.listAllUser(pd):userService.listAllUser(pd);
- zcount = userList.size();
- try {
- for(int i=0;i<userList.size();i++){
- if(Tools.checkMobileNumber(userList.get(i).getString("PHONE"))){ //手机号格式不对就跳过
- if("1".equals(TYPE)){
- SmsUtil.sendSms1(userList.get(i).getString("PHONE"), CONTENT); //调用发短信函数1
- }else{
- SmsUtil.sendSms2(userList.get(i).getString("PHONE"), CONTENT); //调用发短信函数2
- }
- count++;
- }else{
- continue;
- }
- }
- msg = "ok";
- } catch (Exception e) {
- msg = "error";
- }
- } catch (Exception e) {
- msg = "error";
- }
- }else{
- PHONEs = PHONEs.replaceAll(";", ";");
- PHONEs = PHONEs.replaceAll(" ", "");
- String[] arrTITLE = PHONEs.split(";");
- zcount = arrTITLE.length;
- try {
- for(int i=0;i<arrTITLE.length;i++){
- if(Tools.checkMobileNumber(arrTITLE[i])){ //手机号式不对就跳过
- if("1".equals(TYPE)){
- SmsUtil.sendSms1(arrTITLE[i], CONTENT); //调用发短信函数1
- }else{
- SmsUtil.sendSms2(arrTITLE[i], CONTENT); //调用发短信函数2
- }
- count++;
- }else{
- continue;
- }
- }
- msg = "ok";
- } catch (Exception e) {
- msg = "error";
- }
- }
- pd.put("msg", msg);
- pd.put("count", count); //成功数
- pd.put("ecount", zcount-count); //失败数
- pdList.add(pd);
- map.put("list", pdList);
- return AppUtil.returnObject(pd, map);
- }
-
- /**去发送电子邮件页面
- * @return
- * @throws Exception
- */
- @RequestMapping(value="/goSendEmail")
- public ModelAndView goSendEmail() throws Exception{
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- mv.setViewName("system/head/send_email");
- mv.addObject("pd", pd);
- return mv;
- }
-
- /**发送电子邮件
- * @return
- */
- /*@RequestMapping(value="/sendEmail")
- @ResponseBody
- public Object sendEmail(){
- PageData pd = new PageData();
- pd = this.getPageData();
- Map<String,Object> map = new HashMap<String,Object>();
- String msg = "ok"; //发送状态
- int count = 0; //统计发送成功条数
- int zcount = 0; //理论条数
- String strEMAIL = Tools.readTxtFile(Const.EMAIL); //读取邮件配置
- List<PageData> pdList = new ArrayList<PageData>();
- String toEMAIL = pd.getString("EMAIL"); //对方邮箱
- String TITLE = pd.getString("TITLE"); //标题
- String CONTENT = pd.getString("CONTENT"); //内容
- String TYPE = pd.getString("TYPE"); //类型
- String isAll = pd.getString("isAll"); //是否发送给全体成员 yes or no
- String fmsg = pd.getString("fmsg"); //判断是系统用户还是会员 "appuser"为会员用户
- if(null != strEMAIL && !"".equals(strEMAIL)){
- String strEM[] = strEMAIL.split(",fh,");
- if(strEM.length == 4){
- if("yes".endsWith(isAll)){
- try {
- List<PageData> userList = new ArrayList<PageData>();
- userList = "appuser".equals(fmsg) ? appuserService.listAllUser(pd):userService.listAllUser(pd);
- zcount = userList.size();
- try {
- for(int i=0;i<userList.size();i++){
- if(Tools.checkEmail(userList.get(i).getString("EMAIL"))){ //邮箱格式不对就跳过
- SimpleMailSender.sendEmail(strEM[0], strEM[1], strEM[2], strEM[3], userList.get(i).getString("EMAIL"), TITLE, CONTENT, TYPE);//调用发送邮件函数
- count++;
- }else{
- continue;
- }
- }
- msg = "ok";
- } catch (Exception e) {
- msg = "error";
- }
- } catch (Exception e) {
- msg = "error";
- }
- }else{
- toEMAIL = toEMAIL.replaceAll(";", ";");
- toEMAIL = toEMAIL.replaceAll(" ", "");
- String[] arrTITLE = toEMAIL.split(";");
- zcount = arrTITLE.length;
- try {
- for(int i=0;i<arrTITLE.length;i++){
- if(Tools.checkEmail(arrTITLE[i])){ //邮箱格式不对就跳过
- SimpleMailSender.sendEmail(strEM[0], strEM[1], strEM[2], strEM[3], arrTITLE[i], TITLE, CONTENT, TYPE);//调用发送邮件函数
- count++;
- }else{
- continue;
- }
- }
- msg = "ok";
- } catch (Exception e) {
- msg = "error";
- }
- }
- }else{
- msg = "error";
- }
- }else{
- msg = "error";
- }
- pd.put("msg", msg);
- pd.put("count", count); //成功数
- pd.put("ecount", zcount-count); //失败数
- pdList.add(pd);
- map.put("list", pdList);
- return AppUtil.returnObject(pd, map);
- }*/
-
- /**去系统设置页面
- * @return
- * @throws Exception
- */
- @RequestMapping(value="/goSystem")
- public ModelAndView goEditEmail() throws Exception{
- if(!"admin".equals(Jurisdiction.getUsername())){return null;} //非admin用户不能修改
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- pd.put("YSYNAME", Tools.readTxtFile(Const.SYSNAME)); //读取系统名称
- pd.put("COUNTPAGE", Tools.readTxtFile(Const.PAGE)); //读取每页条数
- String strEMAIL = Tools.readTxtFile(Const.EMAIL); //读取邮件配置
- String strSMS1 = Tools.readTxtFile(Const.SMS1); //读取短信1配置
- String strSMS2 = Tools.readTxtFile(Const.SMS2); //读取短信2配置
- String strFWATERM = Tools.readTxtFile(Const.FWATERM); //读取文字水印配置
- String strIWATERM = Tools.readTxtFile(Const.IWATERM); //读取图片水印配置
- pd.put("Token", Tools.readTxtFile(Const.WEIXIN)); //读取微信配置
- String strWEBSOCKET = Tools.readTxtFile(Const.WEBSOCKET);//读取WEBSOCKET配置
- String strLOGINEDIT = Tools.readTxtFile(Const.LOGINEDIT);//读取登录页面配置
- if(null != strEMAIL && !"".equals(strEMAIL)){
- String strEM[] = strEMAIL.split(",fh,");
- if(strEM.length == 4){
- pd.put("SMTP", strEM[0]);
- pd.put("PORT", strEM[1]);
- pd.put("EMAIL", strEM[2]);
- pd.put("PAW", strEM[3]);
- }
- }
- if(null != strSMS1 && !"".equals(strSMS1)){
- String strS1[] = strSMS1.split(",fh,");
- if(strS1.length == 2){
- pd.put("SMSU1", strS1[0]);
- pd.put("SMSPAW1", strS1[1]);
- }
- }
- if(null != strSMS2 && !"".equals(strSMS2)){
- String strS2[] = strSMS2.split(",fh,");
- if(strS2.length == 2){
- pd.put("SMSU2", strS2[0]);
- pd.put("SMSPAW2", strS2[1]);
- }
- }
- if(null != strFWATERM && !"".equals(strFWATERM)){
- String strFW[] = strFWATERM.split(",fh,");
- if(strFW.length == 5){
- pd.put("isCheck1", strFW[0]);
- pd.put("fcontent", strFW[1]);
- pd.put("fontSize", strFW[2]);
- pd.put("fontX", strFW[3]);
- pd.put("fontY", strFW[4]);
- }
- }
- if(null != strIWATERM && !"".equals(strIWATERM)){
- String strIW[] = strIWATERM.split(",fh,");
- if(strIW.length == 4){
- pd.put("isCheck2", strIW[0]);
- pd.put("imgUrl", strIW[1]);
- pd.put("imgX", strIW[2]);
- pd.put("imgY", strIW[3]);
- }
- }
- if(null != strWEBSOCKET && !"".equals(strWEBSOCKET)){
- String strIW[] = strWEBSOCKET.split(",fh,");
- if(strIW.length == 7){
- pd.put("WIMIP", strIW[0]);
- pd.put("WIMPORT", strIW[1]);
- pd.put("OLIP", strIW[2]);
- pd.put("OLPORT", strIW[3]);
- pd.put("FHsmsSound", strIW[4]);
- pd.put("VIDEOIP", strIW[5]);
- pd.put("VIDEOPORT", strIW[6]);
- }
- }
- if(null != strLOGINEDIT && !"".equals(strLOGINEDIT)){
- String strLo[] = strLOGINEDIT.split(",fh,");
- if(strLo.length == 2){
- pd.put("isZhuce", strLo[0]);
- pd.put("isMusic", strLo[1]);
- }
- }
- mv.setViewName("system/head/sys_edit");
- mv.addObject("pd", pd);
- return mv;
- }
-
- /**保存系统设置1
- * @return
- * @throws Exception
- */
- @RequestMapping(value="/saveSys")
- public ModelAndView saveSys() throws Exception{
- if(!"admin".equals(Jurisdiction.getUsername())){return null;} //非admin用户不能修改
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- Tools.writeFile(Const.SYSNAME,pd.getString("YSYNAME")); //写入系统名称
- Tools.writeFile(Const.PAGE,pd.getString("COUNTPAGE")); //写入每页条数
- Tools.writeFile(Const.EMAIL,pd.getString("SMTP")+",fh,"+pd.getString("PORT")+",fh,"+pd.getString("EMAIL")+",fh,"+pd.getString("PAW")); //写入邮件服务器配置
- Tools.writeFile(Const.SMS1,pd.getString("SMSU1")+",fh,"+pd.getString("SMSPAW1")); //写入短信1配置
- Tools.writeFile(Const.SMS2,pd.getString("SMSU2")+",fh,"+pd.getString("SMSPAW2")); //写入短信2配置
- mv.addObject("msg","OK");
- mv.setViewName("save_result");
- return mv;
- }
-
- /**保存系统设置2
- * @return
- * @throws Exception
- */
- @RequestMapping(value="/saveSys2")
- public ModelAndView saveSys2() throws Exception{
- if(!"admin".equals(Jurisdiction.getUsername())){return null;} //非admin用户不能修改
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- Tools.writeFile(Const.FWATERM,pd.getString("isCheck1")+",fh,"+pd.getString("fcontent")+",fh,"+pd.getString("fontSize")+",fh,"+pd.getString("fontX")+",fh,"+pd.getString("fontY")); //文字水印配置
- Tools.writeFile(Const.IWATERM,pd.getString("isCheck2")+",fh,"+pd.getString("imgUrl")+",fh,"+pd.getString("imgX")+",fh,"+pd.getString("imgY")); //图片水印配置
- Watermark.fushValue();
- mv.addObject("msg","OK");
- mv.setViewName("save_result");
- return mv;
- }
-
- /**保存系统设置3
- * @return
- * @throws Exception
- */
- @RequestMapping(value="/saveSys3")
- public ModelAndView saveSys3() throws Exception{
- if(!"admin".equals(Jurisdiction.getUsername())){return null;} //非admin用户不能修改
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- String winStr = pd.getString("WIMIP")+",fh,"+pd.getString("WIMPORT")+",fh,"; //即时通讯配置
- String olStr = pd.getString("OLIP")+",fh,"+pd.getString("OLPORT")+",fh,"+pd.getString("FHsmsSound")+",fh,"; //站内信配置
- String videoStr = pd.getString("VIDEOIP")+",fh,"+pd.getString("VIDEOPORT"); //视频弹幕配置
- Tools.writeFile(Const.WEBSOCKET,winStr+olStr+videoStr); //websocket配置
- mv.addObject("msg","OK");
- mv.setViewName("save_result");
- return mv;
- }
-
- /**保存系统设置4
- * @return
- * @throws Exception
- */
- @RequestMapping(value="/saveSys4")
- public ModelAndView saveSys4() throws Exception{
- if(!"admin".equals(Jurisdiction.getUsername())){return null;} //非admin用户不能修改
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- Tools.writeFile(Const.WEIXIN,pd.getString("Token")); //写入微信配置
- Tools.writeFile(Const.LOGINEDIT,pd.getString("isZhuce")+",fh,"+pd.getString("isMusic")); //登录页面配置
- mv.addObject("msg","OK");
- mv.setViewName("save_result");
- return mv;
- }
-
- }
- // F-H Q 3-135-9679-0
|