Commit 6752b39e97c77463c4832844b9eb3c1c0af6db85
1 parent
096158f6
浦东公交计划调度功能优化
1、首页提示人员停用信息后端逻辑修正,改成当前时间开始的排班计划中有人员停用的线路,排班日期信息,并且当前用户已经分配了运营计划管理模块目录
Showing
4 changed files
with
67 additions
and
57 deletions
src/main/java/com/bsth/controller/schedule/core/legacy/EmployeeConfigInfoController.java
| @@ -61,13 +61,10 @@ public class EmployeeConfigInfoController extends BController<EmployeeConfigInfo | @@ -61,13 +61,10 @@ public class EmployeeConfigInfoController extends BController<EmployeeConfigInfo | ||
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | @RequestMapping(value = "/validate_get_destroy_info", method = RequestMethod.GET) | 63 | @RequestMapping(value = "/validate_get_destroy_info", method = RequestMethod.GET) |
| 64 | - public Map<String, Object> validate_get_destroy_info(HttpServletRequest request) { | ||
| 65 | - HttpSession session = request.getSession(); | ||
| 66 | - List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | ||
| 67 | - | 64 | + public Map<String, Object> validate_get_destroy_info() { |
| 68 | Map<String, Object> rtn = new HashMap<>(); | 65 | Map<String, Object> rtn = new HashMap<>(); |
| 69 | try { | 66 | try { |
| 70 | - rtn.put("data", this.employeeConfigInfoService.validate_get_destroy_info(cmyAuths)); | 67 | + rtn.put("data", this.employeeConfigInfoService.validate_get_destory_info()); |
| 71 | rtn.put("status", ResponseCode.SUCCESS); | 68 | rtn.put("status", ResponseCode.SUCCESS); |
| 72 | } catch (Exception exp) { | 69 | } catch (Exception exp) { |
| 73 | rtn.put("status", ResponseCode.ERROR); | 70 | rtn.put("status", ResponseCode.ERROR); |
| @@ -77,21 +74,17 @@ public class EmployeeConfigInfoController extends BController<EmployeeConfigInfo | @@ -77,21 +74,17 @@ public class EmployeeConfigInfoController extends BController<EmployeeConfigInfo | ||
| 77 | return rtn; | 74 | return rtn; |
| 78 | } | 75 | } |
| 79 | @GetMapping(value = "/validate_get_destroy_info/download") | 76 | @GetMapping(value = "/validate_get_destroy_info/download") |
| 80 | - public void exportValidateGetDestroyInfo( | ||
| 81 | - HttpServletRequest request, | ||
| 82 | - HttpServletResponse response) throws Exception { | 77 | + public void exportValidateGetDestroyInfo(HttpServletResponse response) throws Exception { |
| 83 | // 流输出导出文件 | 78 | // 流输出导出文件 |
| 84 | response.setHeader("content-type", "application/octet-stream"); | 79 | response.setHeader("content-type", "application/octet-stream"); |
| 85 | - response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("人员配置停用信息.txt", "UTF-8")); | 80 | + response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("排班人员停用信息.txt", "UTF-8")); |
| 86 | response.setContentType("application/octet-stream"); | 81 | response.setContentType("application/octet-stream"); |
| 87 | 82 | ||
| 88 | try ( | 83 | try ( |
| 89 | OutputStream os = response.getOutputStream(); | 84 | OutputStream os = response.getOutputStream(); |
| 90 | PrintWriter printWriter = new PrintWriter(os); | 85 | PrintWriter printWriter = new PrintWriter(os); |
| 91 | ) { | 86 | ) { |
| 92 | - HttpSession session = request.getSession(); | ||
| 93 | - List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | ||
| 94 | - List<String> infos = this.employeeConfigInfoService.validate_get_destroy_info(cmyAuths); | 87 | + List<String> infos = this.employeeConfigInfoService.validate_get_destory_info(); |
| 95 | for (String info : infos) { | 88 | for (String info : infos) { |
| 96 | printWriter.println(info); | 89 | printWriter.println(info); |
| 97 | } | 90 | } |
src/main/java/com/bsth/service/schedule/EmployeeConfigInfoService.java
| @@ -30,8 +30,8 @@ public interface EmployeeConfigInfoService extends BService<EmployeeConfigInfo, | @@ -30,8 +30,8 @@ public interface EmployeeConfigInfoService extends BService<EmployeeConfigInfo, | ||
| 30 | void validate_jsy_destroy(EmployeeConfigInfo employeeConfigInfo) throws ScheduleException; | 30 | void validate_jsy_destroy(EmployeeConfigInfo employeeConfigInfo) throws ScheduleException; |
| 31 | // 验证售票员是否停用 | 31 | // 验证售票员是否停用 |
| 32 | void validate_spy_destroy(EmployeeConfigInfo employeeConfigInfo) throws ScheduleException; | 32 | void validate_spy_destroy(EmployeeConfigInfo employeeConfigInfo) throws ScheduleException; |
| 33 | - // 获取线路人员配置停用信息描述 | ||
| 34 | - List<String> validate_get_destroy_info(List<CompanyAuthority> companyAuthorityList); | 33 | + // 获取人员停用信息(使用排班信息辅助判定) |
| 34 | + List<String> validate_get_destory_info(); | ||
| 35 | 35 | ||
| 36 | void toggleCancel(Long id) throws ScheduleException; | 36 | void toggleCancel(Long id) throws ScheduleException; |
| 37 | Long getMaxDbbm(Integer xlId); | 37 | Long getMaxDbbm(Integer xlId); |
src/main/java/com/bsth/service/schedule/impl/EmployeeConfigInfoServiceImpl.java
| @@ -4,6 +4,7 @@ import com.bsth.entity.Personnel; | @@ -4,6 +4,7 @@ import com.bsth.entity.Personnel; | ||
| 4 | import com.bsth.entity.schedule.EmployeeConfigInfo; | 4 | import com.bsth.entity.schedule.EmployeeConfigInfo; |
| 5 | import com.bsth.entity.schedule.rule.ScheduleRule1Flat; | 5 | import com.bsth.entity.schedule.rule.ScheduleRule1Flat; |
| 6 | import com.bsth.entity.sys.CompanyAuthority; | 6 | import com.bsth.entity.sys.CompanyAuthority; |
| 7 | +import com.bsth.entity.sys.Module; | ||
| 7 | import com.bsth.repository.PersonnelRepository; | 8 | import com.bsth.repository.PersonnelRepository; |
| 8 | import com.bsth.service.schedule.EmployeeConfigInfoService; | 9 | import com.bsth.service.schedule.EmployeeConfigInfoService; |
| 9 | import com.bsth.service.schedule.EmployeeService; | 10 | import com.bsth.service.schedule.EmployeeService; |
| @@ -11,11 +12,15 @@ import com.bsth.service.schedule.ScheduleRule1FlatService; | @@ -11,11 +12,15 @@ import com.bsth.service.schedule.ScheduleRule1FlatService; | ||
| 11 | import com.bsth.service.schedule.exception.ScheduleException; | 12 | import com.bsth.service.schedule.exception.ScheduleException; |
| 12 | import com.bsth.service.schedule.utils.DataToolsFile; | 13 | import com.bsth.service.schedule.utils.DataToolsFile; |
| 13 | import com.bsth.service.schedule.utils.DataToolsService; | 14 | import com.bsth.service.schedule.utils.DataToolsService; |
| 15 | +import com.bsth.service.sys.ModuleService; | ||
| 16 | +import com.bsth.util.DateUtils; | ||
| 17 | +import org.apache.commons.lang3.time.DateFormatUtils; | ||
| 14 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | import org.springframework.beans.factory.annotation.Qualifier; | 19 | import org.springframework.beans.factory.annotation.Qualifier; |
| 16 | import org.springframework.dao.DataAccessException; | 20 | import org.springframework.dao.DataAccessException; |
| 17 | import org.springframework.jdbc.core.JdbcTemplate; | 21 | import org.springframework.jdbc.core.JdbcTemplate; |
| 18 | import org.springframework.jdbc.core.ResultSetExtractor; | 22 | import org.springframework.jdbc.core.ResultSetExtractor; |
| 23 | +import org.springframework.jdbc.core.RowMapper; | ||
| 19 | import org.springframework.stereotype.Service; | 24 | import org.springframework.stereotype.Service; |
| 20 | import org.springframework.transaction.annotation.Transactional; | 25 | import org.springframework.transaction.annotation.Transactional; |
| 21 | import org.springframework.util.CollectionUtils; | 26 | import org.springframework.util.CollectionUtils; |
| @@ -277,51 +282,54 @@ public class EmployeeConfigInfoServiceImpl extends BServiceImpl<EmployeeConfigIn | @@ -277,51 +282,54 @@ public class EmployeeConfigInfoServiceImpl extends BServiceImpl<EmployeeConfigIn | ||
| 277 | } | 282 | } |
| 278 | } | 283 | } |
| 279 | 284 | ||
| 285 | + @Autowired | ||
| 286 | + private ModuleService moduleService; | ||
| 280 | @Transactional | 287 | @Transactional |
| 281 | @Override | 288 | @Override |
| 282 | - public List<String> validate_get_destroy_info(List<CompanyAuthority> companyAuthorityList) { | ||
| 283 | - // 获取公司分公司权限代码 | ||
| 284 | - List<String> gs_fgs_dms = new ArrayList<>(); | ||
| 285 | - for (CompanyAuthority companyAuthority : companyAuthorityList) { | ||
| 286 | - gs_fgs_dms.add(companyAuthority.getCompanyCode() + "_" + companyAuthority.getSubCompanyCode()); | ||
| 287 | - } | ||
| 288 | - | ||
| 289 | - // 查询所有人员配置,不用in操作符,n+1查询慢,程序过滤 | ||
| 290 | - Map<String, Object> params = new HashMap<>(); | ||
| 291 | - List<EmployeeConfigInfo> employeeConfigInfoList_all = (List<EmployeeConfigInfo>) this.list(params); | ||
| 292 | - List<EmployeeConfigInfo> employeeConfigInfoList = new ArrayList<>(); | ||
| 293 | - for (EmployeeConfigInfo employeeConfigInfo : employeeConfigInfoList_all) { | ||
| 294 | - if (gs_fgs_dms.contains(employeeConfigInfo.getXl().getCgsbm())) { | ||
| 295 | - employeeConfigInfoList.add(employeeConfigInfo); | 289 | + public List<String> validate_get_destory_info() { |
| 290 | + // 1、查找当前用户是否有运营计划管理,没有的话不分析是否有停用人鱼信息 | ||
| 291 | + List<Module> moduleList = this.moduleService.findByCurrentUser(); | ||
| 292 | + boolean hasPlanModule = false; | ||
| 293 | + for (Module module : moduleList) { | ||
| 294 | + if ("运营计划管理".equals(module.getName())) { | ||
| 295 | + hasPlanModule = true; | ||
| 296 | + break; | ||
| 296 | } | 297 | } |
| 297 | } | 298 | } |
| 299 | + if (!hasPlanModule) { | ||
| 300 | + return null; | ||
| 301 | + } | ||
| 298 | 302 | ||
| 299 | - // 停用信息 | ||
| 300 | - List<String> destroy_infos = new ArrayList<>(); | ||
| 301 | - String info_format = "线路[%s]中人员配置有停用人员,请处理!"; | ||
| 302 | - String info = ""; | ||
| 303 | - Integer xlId = null; | ||
| 304 | - for (EmployeeConfigInfo employeeConfigInfo : employeeConfigInfoList) { | ||
| 305 | - if (employeeConfigInfo.getJsy() != null && | ||
| 306 | - employeeConfigInfo.getJsy().getDestroy() != null && | ||
| 307 | - employeeConfigInfo.getJsy().getDestroy() == 1) { // 驾驶员判定是否停用 | ||
| 308 | - info = String.format(info_format, employeeConfigInfo.getXl().getName()); | ||
| 309 | - if (!destroy_infos.contains(info)) { | ||
| 310 | - destroy_infos.add(info); | ||
| 311 | - } | ||
| 312 | - } | ||
| 313 | - | ||
| 314 | - if (employeeConfigInfo.getSpy() != null && | ||
| 315 | - employeeConfigInfo.getSpy().getDestroy() != null && | ||
| 316 | - employeeConfigInfo.getSpy().getDestroy() == 1) { | ||
| 317 | - info = String.format(info_format, employeeConfigInfo.getXl().getName()); | ||
| 318 | - if (!destroy_infos.contains(info)) { | ||
| 319 | - destroy_infos.add(info); | ||
| 320 | - } | 303 | + // 2、计算从当前时间开始的排班计划中是否有停用人员 |
| 304 | + String sql = | ||
| 305 | + "select distinct " + | ||
| 306 | + "pinfo.xl_name xlName " + | ||
| 307 | + ", pinfo.schedule_date scheduleDate " + | ||
| 308 | + "from " + | ||
| 309 | + "(" + | ||
| 310 | + "select plan.xl_name, plan.schedule_date " + | ||
| 311 | + "from bsth_c_s_sp_info plan " + | ||
| 312 | + "left join bsth_c_personnel jsy on plan.j = jsy.id " + | ||
| 313 | + "left join bsth_c_personnel spy on plan.s = spy.id " + | ||
| 314 | + "where schedule_date >= ? " + | ||
| 315 | + "and (jsy.destroy = 1 || spy.destroy = 1) " + | ||
| 316 | + "order by plan.xl_name asc, plan.schedule_date asc " + | ||
| 317 | + ") pinfo " + | ||
| 318 | + "group by pinfo.xl_name, pinfo.schedule_date "; | ||
| 319 | + | ||
| 320 | + Date currentDate = new Date(DateUtils.getTimestamp()); | ||
| 321 | + System.out.println(currentDate); | ||
| 322 | + String info_format = "线路[%s][%s]排班中有人员已经停用,请及时处理!"; | ||
| 323 | + List<String> infoList = this.jdbcTemplate.query(sql, new Object[] {currentDate}, new RowMapper<String>() { | ||
| 324 | + @Override | ||
| 325 | + public String mapRow(ResultSet resultSet, int i) throws SQLException { | ||
| 326 | + String xlName = resultSet.getString("xlName"); | ||
| 327 | + Date scheduleDate = new Date(resultSet.getDate("scheduleDate").getTime()); | ||
| 328 | + return String.format(info_format, xlName, DateFormatUtils.format(scheduleDate, "yyyy年MM月dd日")); | ||
| 321 | } | 329 | } |
| 322 | - } | 330 | + }); |
| 323 | 331 | ||
| 324 | - return destroy_infos; | 332 | + return infoList; |
| 325 | } | 333 | } |
| 326 | 334 | ||
| 327 | @Transactional | 335 | @Transactional |
src/main/resources/static/pages/home.html
| @@ -83,15 +83,24 @@ | @@ -83,15 +83,24 @@ | ||
| 83 | success: function(rs) { | 83 | success: function(rs) { |
| 84 | if (rs && rs.status === "SUCCESS") { | 84 | if (rs && rs.status === "SUCCESS") { |
| 85 | if (rs.data && rs.data.length && rs.data.length > 0) { | 85 | if (rs.data && rs.data.length && rs.data.length > 0) { |
| 86 | - var text = ""; | 86 | + var htmlText = ""; |
| 87 | + var wrapData = []; | ||
| 87 | if (rs.data.length > 8) { | 88 | if (rs.data.length > 8) { |
| 88 | - text = "部分停用信息如下:</br>" + rs.data.slice(0, 8).join("</br>"); | 89 | + htmlText = "<span style='font-weight: bold; font-style: italic; '>部分停用信息如下:</span></br>"; |
| 90 | + wrapData = rs.data.slice(0, 8); | ||
| 89 | } else { | 91 | } else { |
| 90 | - text = "所有停用信息如下:</br>" + rs.data.join("</br>"); | 92 | + htmlText = "<span style='font-weight: bold; font-style: italic; '>所有停用信息如下:</span></br>"; |
| 93 | + wrapData = rs.data; | ||
| 91 | } | 94 | } |
| 95 | + $.each(wrapData, function(index, value) { | ||
| 96 | + wrapData[index] = "<span style='font-size: 14px;'>" + value + "</span>"; | ||
| 97 | + }); | ||
| 98 | + | ||
| 99 | + htmlText += wrapData.join("</br>"); | ||
| 100 | + | ||
| 92 | swal({ | 101 | swal({ |
| 93 | - title: "人员配置停用信息", | ||
| 94 | - text: text, | 102 | + title: "排班人员停用信息", |
| 103 | + text: htmlText, | ||
| 95 | html: true, | 104 | html: true, |
| 96 | type: "warning", | 105 | type: "warning", |
| 97 | showCancelButton: true, | 106 | showCancelButton: true, |