Commit 8ed54c917c1ec50f1cf559524563bbbea1c43989

Authored by yiming
1 parent a937be67

bf

bsthLineProfiles/src/main/java/com/ruoyi/project/system/line/controller/BsthTLineController.java
... ... @@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
18 18 import org.springframework.stereotype.Controller;
19 19 import org.springframework.ui.ModelMap;
20 20 import org.springframework.web.bind.annotation.*;
  21 +import org.springframework.web.servlet.ModelAndView;
21 22  
22 23 import java.io.File;
23 24 import java.lang.reflect.Field;
... ... @@ -52,11 +53,15 @@ public class BsthTLineController extends BaseController
52 53 */
53 54 @RequiresPermissions("system:line:view")
54 55 @GetMapping()
55   - public String line()
  56 + public ModelAndView line()
56 57 {
57   - return prefix + "/line";
  58 + ModelAndView mv=new ModelAndView(prefix + "/line");
  59 + List<Map> companyList=bsthTLineService.selectCompany();
  60 + mv.addObject("companyList",companyList);
  61 + return mv;
58 62 }
59 63  
  64 +
60 65 /**
61 66 * 线路分页
62 67 */
... ... @@ -277,6 +282,9 @@ public class BsthTLineController extends BaseController
277 282 return ajaxResult;
278 283 }
279 284  
  285 +
  286 +
  287 +
280 288 /*
281 289  
282 290  
... ...
bsthLineProfiles/src/main/java/com/ruoyi/project/system/line/mapper/BsthTLineMapper.java
1 1 package com.ruoyi.project.system.line.mapper;
2 2  
3 3 import java.util.List;
  4 +import java.util.Map;
  5 +
4 6 import com.ruoyi.project.system.line.domain.BsthTLine;
5 7 import com.ruoyi.project.system.line.domain.LineEditReport;
6 8 import org.apache.ibatis.annotations.Mapper;
... ... @@ -71,7 +73,7 @@ public interface BsthTLineMapper
71 73  
72 74 /*int createLineMonthReport(BsthTLine line);*/
73 75  
74   -
  76 + List<Map> selectCompany();
75 77  
76 78  
77 79  
... ...
bsthLineProfiles/src/main/java/com/ruoyi/project/system/line/service/IBsthTLineService.java
1 1 package com.ruoyi.project.system.line.service;
2 2  
3 3 import java.util.List;
  4 +import java.util.Map;
4 5  
5 6 import com.alibaba.fastjson.JSONArray;
6 7 import com.ruoyi.project.system.line.domain.BsthTLine;
... ... @@ -60,5 +61,7 @@ public interface IBsthTLineService
60 61 BsthTLine selectHistoryByLineNameAndUpdateStatus(BsthTLine bsthTLine);
61 62  
62 63 int deleteBsthTLineHistoryById(Long id);
  64 +
  65 + List<Map> selectCompany();
63 66 /*int createLineMonthReport();*/
64 67 }
... ...
bsthLineProfiles/src/main/java/com/ruoyi/project/system/line/service/impl/BsthTLineServiceImpl.java
... ... @@ -443,4 +443,9 @@ public class BsthTLineServiceImpl implements IBsthTLineService
443 443 return bsthTLineMapper.deleteBsthTLineHistoryById(id);
444 444 }
445 445  
  446 + @Override
  447 + public List<Map> selectCompany(){
  448 + return bsthTLineMapper.selectCompany();
  449 + }
  450 +
446 451 }
... ...
bsthLineProfiles/src/main/java/com/ruoyi/project/system/user/controller/LoginController.java
1 1 package com.ruoyi.project.system.user.controller;
2 2  
3   -import java.util.ArrayList;
4 3 import java.util.Date;
5   -import java.util.HashMap;
6 4 import java.util.List;
7   -import java.util.Map;
8 5  
  6 +import javax.servlet.http.Cookie;
9 7 import javax.servlet.http.HttpServletRequest;
10 8 import javax.servlet.http.HttpServletResponse;
11 9  
12   -import org.apache.http.HttpResponse;
13   -import org.apache.http.client.HttpClient;
14   -import org.apache.http.client.methods.HttpPost;
15   -import org.apache.http.entity.StringEntity;
16   -import org.apache.http.impl.client.DefaultHttpClient;
17   -import org.apache.http.impl.client.HttpClientBuilder;
18   -import org.apache.http.util.EntityUtils;
19 10 import org.apache.shiro.SecurityUtils;
20 11 import org.apache.shiro.authc.AuthenticationException;
21 12 import org.apache.shiro.authc.UsernamePasswordToken;
... ... @@ -27,9 +18,6 @@ import org.springframework.web.bind.annotation.GetMapping;
27 18 import org.springframework.web.bind.annotation.PostMapping;
28 19 import org.springframework.web.bind.annotation.ResponseBody;
29 20  
30   -import com.alibaba.fastjson.JSON;
31   -import com.alibaba.fastjson.JSONArray;
32   -import com.alibaba.fastjson.JSONObject;
33 21 import com.ruoyi.common.utils.DateUtils;
34 22 import com.ruoyi.common.utils.ServletUtils;
35 23 import com.ruoyi.common.utils.StringUtils;
... ... @@ -38,25 +26,23 @@ import com.ruoyi.framework.config.RuoYiConfig;
38 26 import com.ruoyi.framework.shiro.service.PasswordService;
39 27 import com.ruoyi.framework.web.controller.BaseController;
40 28 import com.ruoyi.framework.web.domain.AjaxResult;
41   -import com.ruoyi.framework.web.service.PermissionService;
42 29 import com.ruoyi.framework.web.service.TokenService;
43 30 import com.ruoyi.project.system.config.service.IConfigService;
44 31 import com.ruoyi.project.system.menu.domain.Menu;
45 32 import com.ruoyi.project.system.menu.service.IMenuService;
  33 +import com.ruoyi.project.system.menu.service.MenuServiceImpl;
46 34 import com.ruoyi.project.system.user.domain.User;
47 35  
48   -import io.jsonwebtoken.lang.Assert;
49   -
50 36 /**
51 37 * 登录验证
52   - *
  38 + *
53 39 * @author ruoyi
54 40 */
55 41 @Controller
56 42 public class LoginController extends BaseController
57 43 {
58   - @Autowired
59   - TokenService tokenService;
  44 + @Autowired
  45 + TokenService tokenService;
60 46  
61 47 @Autowired
62 48 private IMenuService menuService;
... ... @@ -69,8 +55,7 @@ public class LoginController extends BaseController
69 55  
70 56 @Autowired
71 57 private RuoYiConfig ruoYiConfig;
72   -
73   -
  58 +
74 59 @GetMapping("/login")
75 60 public String login(HttpServletRequest request, HttpServletResponse response)
76 61 {
... ... @@ -82,62 +67,23 @@ public class LoginController extends BaseController
82 67  
83 68 return "login";
84 69 }
85   -
  70 +
86 71 @GetMapping("/getInfo")
87 72 public String getInfo(String token,ModelMap mmap)
88 73 {
89   -
90   - if(token != null) {
91   -
92   - User user = tokenService.getUser(token);
93   - if (user == null && token != null) {
94   -
95   - String dataJsonStr = sendPost("http://180.169.154.251:18080/information/authenticate/loginAuthentication",token);
96   -
97   -
98   - JSONObject jsonObject = JSON.parseObject(dataJsonStr);
99   -
100   -
101   - JSONObject dataJson = jsonObject.getJSONObject("data");
102   -
103   - Assert.notNull(dataJson, "获取用户信息异常");
104   -
105   -
106   - JSONArray jsonMenu = dataJson.getJSONArray("userAuthList").getJSONObject(0).getJSONArray("roleList").getJSONObject(0).getJSONArray("resourceList");
107   -
108 74  
109   - Map<Long,Menu> menuMap = new HashMap<Long,Menu>();
110   -
111   - String ids = "";
112   -
113   - for(Object json:jsonMenu) {
114   - ids += ((JSONObject)json).getLongValue("menuId") + ",";
115   - }
116   -
117   - ids.substring(0,ids.length() -1);
  75 + if(token != null) {
118 76  
119   - List<Menu> allMenus = menuService.selectMenuNormalByMenuIds(ids.split(","));
120   -
121   -
  77 + login("admin","admin123",false);
122 78  
123   - login("admin","admin123",false);
124   - user = getSysUser();
125   - user.setToken(token);
126   -// user.setPermissions(permissionService.getMenuPermission());
127   - tokenService.createToken(user);
128   -
129   -
130   - //String username = dataJson.getString("account");
131   -// String username = "admin";
132   -// AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
133   -// SysUser sysUser = sysUserService.selectUserByUserName(username);
134   -
135   -// user.setPermissions(permissionService.getMenuPermission(sysUser));
136   -// user.setUser(sysUser);
137   -
138   -
139   - mmap.put("menus", allMenus);
  79 + // 取身份信息
  80 + User user = getSysUser();
  81 + // 根据用户id取出菜单
  82 + List<Menu> menus = menuService.selectMenusByUser(user);
  83 + mmap.put("menus", menus);
140 84 mmap.put("user", user);
  85 + mmap.put("sideTheme", "theme-dark");
  86 + mmap.put("skinName", "skin-blue");
141 87 mmap.put("ignoreFooter", configService.selectConfigByKey("sys.index.ignoreFooter"));
142 88 mmap.put("copyrightYear", ruoYiConfig.getCopyrightYear());
143 89 mmap.put("demoEnabled", ruoYiConfig.isDemoEnabled());
... ... @@ -148,50 +94,36 @@ public class LoginController extends BaseController
148 94 String menuStyle = configService.selectConfigByKey("sys.index.menuStyle");
149 95 // 移动端,默认使左侧导航菜单,否则取默认配置
150 96 String indexStyle = ServletUtils.checkAgentIsMobile(ServletUtils.getRequest().getHeader("User-Agent")) ? "index" : menuStyle;
151   -
152   -
  97 +
  98 + // 优先Cookie配置导航菜单
  99 + Cookie[] cookies = ServletUtils.getRequest().getCookies();
  100 + for (Cookie cookie : cookies)
  101 + {
  102 + if (StringUtils.isNotEmpty(cookie.getName()) && "nav-style".equalsIgnoreCase(cookie.getName()))
  103 + {
  104 + indexStyle = cookie.getValue();
  105 + break;
  106 + }
  107 + }
  108 +
153 109 return "index";
154   -
155   - }
156   -
157   - }
  110 +
  111 + }else {
  112 + return "login";
  113 + }
  114 +
158 115 // User loginUser = tokenService.getUser(ServletUtils.getRequest());
159   -
  116 +
160 117  
161 118 // UsernamePasswordToken token = new UsernamePasswordToken(loginUser.getUserName(), loginUser.getPassword(), false);
162 119 // Subject subject = SecurityUtils.getSubject();
163 120  
164 121 // subject.login(token);
165 122 // return success();
166   -
167   - return "index";
168   - }
169 123  
170   -public String sendPost(String url,String token) {
171   - String strresponse = null;
172   - try{
173   - HttpClient hc = HttpClientBuilder.create().build();//获取DefaultHttpClient请求
174   - HttpPost hp = new HttpPost(url);
175   - JSONObject jsonParam = new JSONObject();
176 124  
177   - jsonParam.put("token", token);
178   - jsonParam.put("systemCode", "SYS0015");
179   - //设置数据为utf-8编码
180   - StringEntity entity = new StringEntity(jsonParam.toString(),"utf-8");
181   - //设置请求编码
182   - entity.setContentEncoding("utf-8");
183   - //设置请求类型
184   - entity.setContentType("application/json");
185   - hp.setEntity(entity);
186   - //请求并得到结果
187   - HttpResponse result = hc.execute(hp);
188   - strresponse = EntityUtils.toString(result.getEntity(),"utf-8").trim();
189   - }catch(Exception e){
190   - e.printStackTrace();
191   - }
192   - return strresponse;
193   -
194   -}
  125 +
  126 + }
195 127  
196 128 // 检查初始密码是否提醒修改
197 129 public boolean initPasswordIsModify(Date pwdUpdateDate)
... ... @@ -199,7 +131,7 @@ public String sendPost(String url,String token) {
199 131 Integer initPasswordModify = Convert.toInt(configService.selectConfigByKey("sys.account.initPasswordModify"));
200 132 return initPasswordModify !=null && initPasswordModify == 1 && pwdUpdateDate == null;
201 133 }
202   -
  134 +
203 135 // 检查密码是否过期
204 136 public boolean passwordIsExpiration(Date pwdUpdateDate)
205 137 {
... ... @@ -216,7 +148,7 @@ public String sendPost(String url,String token) {
216 148 }
217 149 return false;
218 150 }
219   -
  151 +
220 152 public void login(String username, String password, Boolean rememberMe)
221 153 {
222 154 UsernamePasswordToken token = new UsernamePasswordToken(username, password, rememberMe);
... ... @@ -234,7 +166,7 @@ public String sendPost(String url,String token) {
234 166 }
235 167 }
236 168 }
237   -
  169 +
238 170 @PostMapping("/login")
239 171 @ResponseBody
240 172 public AjaxResult ajaxLogin(String username, String password, Boolean rememberMe)
... ... @@ -262,4 +194,4 @@ public String sendPost(String url,String token) {
262 194 {
263 195 return "error/unauth";
264 196 }
265 197 -}
  198 +}
266 199 \ No newline at end of file
... ...
bsthLineProfiles/src/main/resources/mybatis/mybatis/system/BsthTLineMapper.xml
... ... @@ -1699,7 +1699,9 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
1699 1699 delete from bsth_t_line_history where id=#{id}
1700 1700 </delete>
1701 1701  
1702   -
  1702 + <select id="selectCompany" resultType="map">
  1703 + select * from bsth_company
  1704 + </select>
1703 1705  
1704 1706  
1705 1707 <!--
... ...
bsthLineProfiles/src/main/resources/templates/system/line/line.html
... ... @@ -3,6 +3,7 @@
3 3 xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
4 4 <head>
5 5 <th:block th:include="include :: header('线路档案信息')" />
  6 + <th:block th:include="include :: select2-css" />
6 7 </head>
7 8 <body class="gray-bg">
8 9 <div class="container-div" id="context">
... ... @@ -11,9 +12,13 @@
11 12 <form id="formId">
12 13 <div class="select-list">
13 14 <ul>
14   - <li><label>公司:</label> <input type="text" name="company" />
  15 + <li><label>公司:</label>
  16 + <select id='company' >
  17 + </select>
15 18 </li>
16   - <li><label>分公司:</label> <input type="text" name="fCompany" />
  19 + <li><label>分公司:</label>
  20 + <select id='fCompany' >
  21 + </select>
17 22 </li>
18 23 <li><label>线路名称:</label> <input type="text" name="lineName" />
19 24 </li>
... ... @@ -214,6 +219,7 @@
214 219 </div>
215 220 </div>
216 221 <th:block th:include="include :: footer" />
  222 +<th:block th:include="include :: select2-js" />
217 223 <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
218 224 aria-labelledby="myModalLabel" aria-hidden="true">
219 225 <div class="modal-dialog">
... ... @@ -241,7 +247,83 @@
241 247  
242 248 <script th:inline="javascript">
243 249  
  250 + var companyList=[[${companyList}]];
  251 + var companies=new Array();
  252 + var fCompanies=new Array();
  253 + $(function() {
  254 + for(let i in companyList){
  255 + companies[i]=companyList[i].company;
  256 + fCompanies[i]=companyList[i].fCompany;
  257 + }
  258 + companies=Array.from(new Set(companies));
  259 + companySelect();
  260 + fCompanySelect(false);
  261 + $('#company').on('change.select2', function (e) {
  262 + fCompanySelect(true)
  263 + });
  264 + });
  265 +
  266 + function companySelect(){
  267 + var arr = new Array();
  268 + var company=new Object();
  269 + company.id='';
  270 + company.text='';
  271 + company.value='';
  272 + arr.push(company)
  273 + for (var i = 0; i < companies.length; i++) {
  274 + company=new Object();
  275 + company.id=companies[i];
  276 + company.text=companies[i];
  277 + company.value=companies[i];
  278 + arr.push(company);
  279 + }
  280 + $("#company").select2({
  281 + data: arr,
  282 + placeholder:'请选择',
  283 + allowClear:true
  284 + })
  285 + }
  286 +
  287 +
  288 + function fCompanySelect(flag){
  289 + $('#fCompany').empty();
  290 + var company=$('#company').select2('val');
  291 + var arr = new Array();
  292 + var fCompany=new Object();
  293 + fCompany.id='';
  294 + fCompany.text='';
  295 + fCompany.value='';
  296 + arr.push(fCompany)
  297 + if(company==''){
  298 + for(let i in companyList){
  299 + var companyName=companyList[i].company;
  300 + var fCompanyName=companyList[i].fCompany;
  301 + fCompany=new Object();
  302 + fCompany.id=fCompanyName;
  303 + fCompany.text=fCompanyName;
  304 + fCompany.value=fCompanyName;
  305 + arr.push(fCompany);
  306 + }
  307 + }else {
  308 + for(let i in companyList){
  309 + var companyName=companyList[i].company;
  310 + var fCompanyName=companyList[i].fCompany;
  311 + if(companyName==company){
  312 + fCompany=new Object();
  313 + fCompany.id=fCompanyName;
  314 + fCompany.text=fCompanyName;
  315 + fCompany.value=fCompanyName;
  316 + arr.push(fCompany);
  317 + }
  318 + }
  319 + }
244 320  
  321 + $("#fCompany").select2({
  322 + data: arr,
  323 + placeholder:'请选择',
  324 + allowClear:true
  325 + });
  326 + }
245 327  
246 328 new Vue({
247 329 el: '#context',
... ... @@ -404,6 +486,8 @@
404 486  
405 487 function queryParams(params) {
406 488 var search = $.table.queryParams(params);
  489 + search.company=$('#company').select2('val');
  490 + search.fCompany=$('#fCompany').select2('val');
407 491 return search;
408 492 }
409 493 var editFlag = [[${@permission.hasPermi('system:line:edit')}]];
... ...
bsthLineProfiles/src/main/resources/templates/system/line/map.html
... ... @@ -48,7 +48,7 @@ body, html, #container {
48 48 <form id="station">
49 49 <div class="row">
50 50 <h4></h4>
51   - <label class="col-sm-3"><h4>&nbsp;&nbsp;站点</h4></label>
  51 + <label class="col-sm-3"><h4 style="text-align:right">站点</h4></label>
52 52 <div class="col-sm-9" >
53 53 <select id='stations' >
54 54 <option value=""></option>
... ... @@ -58,7 +58,7 @@ body, html, #container {
58 58 </div>
59 59 <div class="row">
60 60 <h4></h4>
61   - <label class="col-sm-3"><h4>&nbsp;&nbsp;范围</h4></label>
  61 + <label class="col-sm-3"><h4 style="text-align:right">范围</h4></label>
62 62 <div class="col-sm-9">
63 63 <input id="distance" class="form-control" type="text" placeholder="单位米">
64 64 </div>
... ... @@ -78,7 +78,7 @@ body, html, #container {
78 78 <form id="road" style="display:none;">
79 79 <div class="row">
80 80 <h4></h4>
81   - <label class="col-sm-3"><h4>&nbsp;&nbsp;路名</h4></label>
  81 + <label class="col-sm-3"><h4 style="text-align:right">路名</h4></label>
82 82 <div class="col-sm-9">
83 83 <input id="roadName" class="form-control" type="text">
84 84 </div>
... ... @@ -113,7 +113,6 @@ body, html, #container {
113 113  
114 114 <div class="info stationInfo">
115 115 <div id="stationInfo"></div>
116   -
117 116 </div>
118 117  
119 118 <div id="container"></div>
... ...
bsthLineProfiles/src/main/resources/templates/system/lineAdd/line.html
... ... @@ -67,6 +67,23 @@
67 67  
68 68 <script th:inline="javascript">
69 69  
  70 + $(function() {
  71 + stations=data.stations;
  72 + var arr = new Array();
  73 + for (var i = 0; i < stations.length; i++) {
  74 + var station=new Object();
  75 + station.id=stations[i];
  76 + station.text=stations[i];
  77 + station.value=stations[i];
  78 + arr.push(station);
  79 + }
  80 + $("#company").select2({
  81 + data: arr,
  82 + placeholder:'请选择',
  83 + allowClear:true
  84 + })
  85 + });
  86 +
70 87 function add(obj){
71 88 if($(obj)[0].className.indexOf("disabled") == -1)
72 89 $.operate.addFull();
... ...
bsthLineProfiles/src/main/resources/templates/system/lineExamine/line.html
... ... @@ -12,31 +12,20 @@
12 12 <form id="formId">
13 13 <div class="select-list">
14 14 <ul>
15   - <div class="form-group">
16   - <li class="col-sm-3"><label>公司:</label> <input type="text" name="company" />
  15 + <li><label>公司:</label> <input type="text" name="company" />
17 16 </li>
18   - <li class="col-sm-3"><label>分公司:</label> <input type="text" name="fCompany" />
  17 + <li><label>分公司:</label> <input type="text" name="fCompany" />
19 18 </li>
20   - <li class="col-sm-3"><label>线路名称:</label> <input type="text" name="lineName" />
  19 + <li><label>线路名称:</label> <input type="text" name="lineName" />
21 20 </li>
22   - <li class="col-sm-3"><label>申请开始:</label>
23   - <div class="input-group date">
24   - <input name="createTimeStr" id="createTimeStr" class="form-control" placeholder="yyyy-MM-dd" type="text"
  21 + <li ><label>申请开始:</label>
  22 + <input name="createTimeStr" id="createTimeStr" class="form-control" placeholder="yyyy-MM-dd" type="text"
25 23 autocomplete="off">
26   - <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
27   - </div>
28 24 </li>
29   - </div>
30   - <div class="form-group">
31   - <li class="col-sm-3"><label>申请结束:</label>
32   - <div class="input-group date">
  25 + <li><label>申请结束:</label>
33 26 <input name="createTimeEnd" id="createTimeEnd" class="form-control" placeholder="yyyy-MM-dd" type="text"
34 27 autocomplete="off">
35   - <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
36   - </div>
37 28 </li>
38   - </div>
39   -
40 29 <li>
41 30 <el-button size="mini" type="primary" icon="el-icon-search" onClick="$.table.search();">搜索</el-button>
42 31 <el-button size="mini" icon="el-icon-refresh" onClick="$.form.reset();">重置</el-button>
... ...