Commit 7cceed4da602bfcc285f75d87c65e68f5badb5fd
1 parent
b8a7ddee
iss提交9:
1、添加使用人员配置服务的controller,把原来的controller放入legacy包中 2、在dubbo消费者配置文件中配置人员配置服务
Showing
4 changed files
with
465 additions
and
4 deletions
src/main/java/com/bsth/controller/schedule/core/CarConfigInfoController.java renamed to src/main/java/com/bsth/controller/schedule/core/CarConfigInfoController_facade.java
| ... | ... | @@ -35,7 +35,7 @@ import java.util.*; |
| 35 | 35 | */ |
| 36 | 36 | @RestController |
| 37 | 37 | @RequestMapping("cci") |
| 38 | -public class CarConfigInfoController extends BController_facade<Long, VehicleConfigDto> { | |
| 38 | +public class CarConfigInfoController_facade extends BController_facade<Long, VehicleConfigDto> { | |
| 39 | 39 | |
| 40 | 40 | @Override |
| 41 | 41 | public void setCreateUserInfo(VehicleConfigDto vehicleConfigDto, Integer userId, Date createDate) { | ... | ... |
src/main/java/com/bsth/controller/schedule/core/EmployeeConfigInfoController_facade.java
0 → 100644
| 1 | +package com.bsth.controller.schedule.core; | |
| 2 | + | |
| 3 | +import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | +import com.bsth.common.Constants; | |
| 5 | +import com.bsth.common.ResponseCode; | |
| 6 | +import com.bsth.control_v2.plan_module.common.dto.baseinfo.LineDto; | |
| 7 | +import com.bsth.control_v2.plan_module.common.dto.baseinfo.PersonnelDto; | |
| 8 | +import com.bsth.control_v2.plan_module.common.dto.schedule.config.EmployeeConfigDto; | |
| 9 | +import com.bsth.control_v2.plan_module.common.dto.sys.CompanyAuthorityDto; | |
| 10 | +import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; | |
| 11 | +import com.bsth.control_v2.plan_module.common.exception.PlanModuleException; | |
| 12 | +import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 13 | +import com.bsth.control_v2.plan_module.common.service.schedule.config.EmployeeConfigServiceFacade; | |
| 14 | +import com.bsth.controller.schedule.BController_facade; | |
| 15 | +import com.bsth.entity.sys.CompanyAuthority; | |
| 16 | +import com.bsth.service.schedule.EmployeeConfigInfoService; | |
| 17 | +import com.bsth.service.schedule.utils.DataToolsFile; | |
| 18 | +import org.apache.commons.lang3.StringUtils; | |
| 19 | +import org.apache.poi.ss.usermodel.Workbook; | |
| 20 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 21 | +import org.springframework.web.bind.annotation.*; | |
| 22 | +import org.springframework.web.multipart.MultipartFile; | |
| 23 | + | |
| 24 | +import javax.servlet.http.HttpServletRequest; | |
| 25 | +import javax.servlet.http.HttpServletResponse; | |
| 26 | +import javax.servlet.http.HttpSession; | |
| 27 | +import java.io.*; | |
| 28 | +import java.util.*; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * Created by xu on 16/5/10. | |
| 32 | + */ | |
| 33 | +@RestController | |
| 34 | +@RequestMapping("eci") | |
| 35 | +public class EmployeeConfigInfoController_facade extends BController_facade<Long, EmployeeConfigDto> { | |
| 36 | + | |
| 37 | + @Override | |
| 38 | + public void setCreateUserInfo(EmployeeConfigDto employeeConfigDto, Integer userId, Date createDate) { | |
| 39 | + UserDto userDto = UserDto.getBuilder() | |
| 40 | + .setId(userId) | |
| 41 | + .build(); | |
| 42 | + employeeConfigDto.setCreateBy(userDto); | |
| 43 | + employeeConfigDto.setCreateDate(createDate); | |
| 44 | + } | |
| 45 | + | |
| 46 | + @Override | |
| 47 | + public void setUpdateUserInfo(EmployeeConfigDto employeeConfigDto, Integer userId, Date updateDate) { | |
| 48 | + UserDto userDto = UserDto.getBuilder() | |
| 49 | + .setId(userId) | |
| 50 | + .build(); | |
| 51 | + employeeConfigDto.setUpdateBy(userDto); | |
| 52 | + employeeConfigDto.setUpdateDate(updateDate); | |
| 53 | + } | |
| 54 | + | |
| 55 | + @Reference | |
| 56 | + private EmployeeConfigServiceFacade employeeConfigServiceFacade; | |
| 57 | + | |
| 58 | + @Override | |
| 59 | + protected BServiceFacade<Long, EmployeeConfigDto> getBServiceFacade() { | |
| 60 | + return employeeConfigServiceFacade; | |
| 61 | + } | |
| 62 | + | |
| 63 | + @RequestMapping(value = "/jsy", method = RequestMethod.GET) | |
| 64 | + public List<Map<String, Object>> findJsyFromConfig() { | |
| 65 | + return employeeConfigServiceFacade.findJsyFromConfig(); | |
| 66 | + } | |
| 67 | + | |
| 68 | + @RequestMapping(value = "/spy", method = RequestMethod.GET) | |
| 69 | + public List<Map<String, Object>> findSpyFromConfig() { | |
| 70 | + return employeeConfigServiceFacade.findSpyFromConfig(); | |
| 71 | + } | |
| 72 | + | |
| 73 | + | |
| 74 | + @RequestMapping(value = "/dbbm/{xlid}", method = RequestMethod.GET) | |
| 75 | + public Map<String, Object> getDbbm(@PathVariable("xlid") Integer xl) { | |
| 76 | + Map<String, Object> rtn = new HashMap<>(); | |
| 77 | + try { | |
| 78 | + rtn.put("data", employeeConfigServiceFacade.getMaxDbbm(xl)); | |
| 79 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 80 | + } catch (Exception exp) { | |
| 81 | + exp.printStackTrace(); | |
| 82 | + rtn.put("status", ResponseCode.ERROR); | |
| 83 | + rtn.put("msg", exp.getMessage()); | |
| 84 | + } | |
| 85 | + return rtn; | |
| 86 | + } | |
| 87 | + | |
| 88 | + @RequestMapping(value = "/validate_jsy", method = RequestMethod.GET) | |
| 89 | + public Map<String, Object> validate_jsy(@RequestParam Map<String, Object> param) { | |
| 90 | + Map<String, Object> rtn = new HashMap<>(); | |
| 91 | + try { | |
| 92 | + EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 93 | + .setId(param.get("id_eq") == null ? null : Long.parseLong(param.get("id_eq").toString())) | |
| 94 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 95 | + LineDto.getBuilder() | |
| 96 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 97 | + .setName(param.get("xl.name_eq").toString()) | |
| 98 | + .build() | |
| 99 | + )) | |
| 100 | + .setJsy(param.get("jsy.id_eq") == null ? null : ( | |
| 101 | + PersonnelDto.getBuilder() | |
| 102 | + .setId(Integer.valueOf(param.get("jsy.id_eq").toString())) | |
| 103 | + .build() | |
| 104 | + )) | |
| 105 | + .build(); | |
| 106 | + employeeConfigServiceFacade.validate_jsy_duplicate_without_current(employeeConfigDto); | |
| 107 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 108 | + } catch (PlanModuleException exp) { | |
| 109 | + rtn.put("status", ResponseCode.ERROR); | |
| 110 | + rtn.put("msg", exp.getMessage()); | |
| 111 | + } | |
| 112 | + | |
| 113 | + return rtn; | |
| 114 | + } | |
| 115 | + | |
| 116 | + @RequestMapping(value = "/validate_jsy_config", method = RequestMethod.GET) | |
| 117 | + public Map<String, Object> validate_jsy_config(@RequestParam Map<String, Object> param) { | |
| 118 | + Map<String, Object> rtn = new HashMap<>(); | |
| 119 | + try { | |
| 120 | + EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 121 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 122 | + LineDto.getBuilder() | |
| 123 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 124 | + .setName(param.get("xl.name_eq").toString()) | |
| 125 | + .build() | |
| 126 | + )) | |
| 127 | + .setJsy(param.get("jsy.id_eq") == null ? null : ( | |
| 128 | + PersonnelDto.getBuilder() | |
| 129 | + .setId(Integer.valueOf(param.get("jsy.id_eq").toString())) | |
| 130 | + .build() | |
| 131 | + )) | |
| 132 | + .build(); | |
| 133 | + employeeConfigServiceFacade.validate_jsy_exist(employeeConfigDto); | |
| 134 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 135 | + } catch (PlanModuleException exp) { | |
| 136 | + rtn.put("status", ResponseCode.ERROR); | |
| 137 | + rtn.put("msg", exp.getMessage()); | |
| 138 | + } | |
| 139 | + | |
| 140 | + return rtn; | |
| 141 | + } | |
| 142 | + | |
| 143 | + @RequestMapping(value = "/validate_jsy_gs", method = RequestMethod.GET) | |
| 144 | + public Map<String, Object> validate_jsy_gs(HttpServletRequest request, @RequestParam Map<String, Object> param) { | |
| 145 | + HttpSession session = request.getSession(); | |
| 146 | + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | |
| 147 | + List<CompanyAuthorityDto> companyAuthorityDtoList = new ArrayList<>(); | |
| 148 | + for (CompanyAuthority companyAuthority : cmyAuths) { | |
| 149 | + CompanyAuthorityDto companyAuthorityDto = CompanyAuthorityDto.getBuilder() | |
| 150 | + .setId(companyAuthority.getId()) | |
| 151 | + .setCompanyCode(companyAuthority.getCompanyCode()) | |
| 152 | + .setCompanyName(companyAuthority.getCompanyName()) | |
| 153 | + .setSubCompanyCode(companyAuthority.getSubCompanyCode()) | |
| 154 | + .setSubCompanyName(companyAuthority.getSubCompanyName()) | |
| 155 | + .build(); | |
| 156 | + companyAuthorityDtoList.add(companyAuthorityDto); | |
| 157 | + } | |
| 158 | + | |
| 159 | + Map<String, Object> rtn = new HashMap<>(); | |
| 160 | + try { | |
| 161 | + EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 162 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 163 | + LineDto.getBuilder() | |
| 164 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 165 | + .setName(param.get("xl.name_eq").toString()) | |
| 166 | + .build() | |
| 167 | + )) | |
| 168 | + .setJsy(param.get("jsy.id_eq") == null ? null : ( | |
| 169 | + PersonnelDto.getBuilder() | |
| 170 | + .setId(Integer.valueOf(param.get("jsy.id_eq").toString())) | |
| 171 | + .build() | |
| 172 | + )) | |
| 173 | + .build(); | |
| 174 | + employeeConfigServiceFacade.validate_jsy_gs_authority(employeeConfigDto, companyAuthorityDtoList); | |
| 175 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 176 | + } catch (PlanModuleException exp) { | |
| 177 | + rtn.put("status", ResponseCode.ERROR); | |
| 178 | + rtn.put("msg", exp.getMessage()); | |
| 179 | + } | |
| 180 | + | |
| 181 | + return rtn; | |
| 182 | + } | |
| 183 | + | |
| 184 | + @RequestMapping(value = "/validate_jsy_fgs", method = RequestMethod.GET) | |
| 185 | + public Map<String, Object> validate_jsy_fgs(HttpServletRequest request, @RequestParam Map<String, Object> param) { | |
| 186 | + HttpSession session = request.getSession(); | |
| 187 | + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | |
| 188 | + List<CompanyAuthorityDto> companyAuthorityDtoList = new ArrayList<>(); | |
| 189 | + for (CompanyAuthority companyAuthority : cmyAuths) { | |
| 190 | + CompanyAuthorityDto companyAuthorityDto = CompanyAuthorityDto.getBuilder() | |
| 191 | + .setId(companyAuthority.getId()) | |
| 192 | + .setCompanyCode(companyAuthority.getCompanyCode()) | |
| 193 | + .setCompanyName(companyAuthority.getCompanyName()) | |
| 194 | + .setSubCompanyCode(companyAuthority.getSubCompanyCode()) | |
| 195 | + .setSubCompanyName(companyAuthority.getSubCompanyName()) | |
| 196 | + .build(); | |
| 197 | + companyAuthorityDtoList.add(companyAuthorityDto); | |
| 198 | + } | |
| 199 | + | |
| 200 | + Map<String, Object> rtn = new HashMap<>(); | |
| 201 | + try { | |
| 202 | + EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 203 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 204 | + LineDto.getBuilder() | |
| 205 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 206 | + .setName(param.get("xl.name_eq").toString()) | |
| 207 | + .build() | |
| 208 | + )) | |
| 209 | + .setJsy(param.get("jsy.id_eq") == null ? null : ( | |
| 210 | + PersonnelDto.getBuilder() | |
| 211 | + .setId(Integer.valueOf(param.get("jsy.id_eq").toString())) | |
| 212 | + .build() | |
| 213 | + )) | |
| 214 | + .build(); | |
| 215 | + employeeConfigServiceFacade.validate_jsy_fgs_authority(employeeConfigDto, companyAuthorityDtoList); | |
| 216 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 217 | + } catch (PlanModuleException exp) { | |
| 218 | + rtn.put("status", ResponseCode.ERROR); | |
| 219 | + rtn.put("msg", exp.getMessage()); | |
| 220 | + } | |
| 221 | + | |
| 222 | + return rtn; | |
| 223 | + } | |
| 224 | + | |
| 225 | + @RequestMapping(value = "/validate_spy", method = RequestMethod.GET) | |
| 226 | + public Map<String, Object> validate_spy(@RequestParam Map<String, Object> param) { | |
| 227 | + Map<String, Object> rtn = new HashMap<>(); | |
| 228 | + try { | |
| 229 | + EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 230 | + .setId(param.get("id_eq") == null ? null : Long.parseLong(param.get("id_eq").toString())) | |
| 231 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 232 | + LineDto.getBuilder() | |
| 233 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 234 | + .setName(param.get("xl.name_eq").toString()) | |
| 235 | + .build() | |
| 236 | + )) | |
| 237 | + .setSpy(param.get("spy.id_eq") == null ? null : ( | |
| 238 | + PersonnelDto.getBuilder() | |
| 239 | + .setId(Integer.valueOf(param.get("spy.id_eq").toString())) | |
| 240 | + .build() | |
| 241 | + )) | |
| 242 | + .build(); | |
| 243 | + employeeConfigServiceFacade.validate_spy_duplicate_without_current(employeeConfigDto); | |
| 244 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 245 | + } catch (PlanModuleException exp) { | |
| 246 | + rtn.put("status", ResponseCode.ERROR); | |
| 247 | + rtn.put("msg", exp.getMessage()); | |
| 248 | + } | |
| 249 | + return rtn; | |
| 250 | + } | |
| 251 | + | |
| 252 | + @RequestMapping(value = "/validate_spy_config", method = RequestMethod.GET) | |
| 253 | + public Map<String, Object> validate_spy_config(@RequestParam Map<String, Object> param) { | |
| 254 | + Map<String, Object> rtn = new HashMap<>(); | |
| 255 | + try { | |
| 256 | + EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 257 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 258 | + LineDto.getBuilder() | |
| 259 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 260 | + .setName(param.get("xl.name_eq").toString()) | |
| 261 | + .build() | |
| 262 | + )) | |
| 263 | + .setSpy(param.get("spy.id_eq") == null ? null : ( | |
| 264 | + PersonnelDto.getBuilder() | |
| 265 | + .setId(Integer.valueOf(param.get("spy.id_eq").toString())) | |
| 266 | + .build() | |
| 267 | + )) | |
| 268 | + .build(); | |
| 269 | + employeeConfigServiceFacade.validate_spy_exist(employeeConfigDto); | |
| 270 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 271 | + } catch (PlanModuleException exp) { | |
| 272 | + rtn.put("status", ResponseCode.ERROR); | |
| 273 | + rtn.put("msg", exp.getMessage()); | |
| 274 | + } | |
| 275 | + return rtn; | |
| 276 | + } | |
| 277 | + | |
| 278 | + @RequestMapping(value = "/validate_spy_gs", method = RequestMethod.GET) | |
| 279 | + public Map<String, Object> validate_spy_gs(HttpServletRequest request, @RequestParam Map<String, Object> param) { | |
| 280 | + HttpSession session = request.getSession(); | |
| 281 | + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | |
| 282 | + List<CompanyAuthorityDto> companyAuthorityDtoList = new ArrayList<>(); | |
| 283 | + for (CompanyAuthority companyAuthority : cmyAuths) { | |
| 284 | + CompanyAuthorityDto companyAuthorityDto = CompanyAuthorityDto.getBuilder() | |
| 285 | + .setId(companyAuthority.getId()) | |
| 286 | + .setCompanyCode(companyAuthority.getCompanyCode()) | |
| 287 | + .setCompanyName(companyAuthority.getCompanyName()) | |
| 288 | + .setSubCompanyCode(companyAuthority.getSubCompanyCode()) | |
| 289 | + .setSubCompanyName(companyAuthority.getSubCompanyName()) | |
| 290 | + .build(); | |
| 291 | + companyAuthorityDtoList.add(companyAuthorityDto); | |
| 292 | + } | |
| 293 | + | |
| 294 | + Map<String, Object> rtn = new HashMap<>(); | |
| 295 | + try { | |
| 296 | + EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 297 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 298 | + LineDto.getBuilder() | |
| 299 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 300 | + .setName(param.get("xl.name_eq").toString()) | |
| 301 | + .build() | |
| 302 | + )) | |
| 303 | + .setSpy(param.get("spy.id_eq") == null ? null : ( | |
| 304 | + PersonnelDto.getBuilder() | |
| 305 | + .setId(Integer.valueOf(param.get("spy.id_eq").toString())) | |
| 306 | + .build() | |
| 307 | + )) | |
| 308 | + .build(); | |
| 309 | + employeeConfigServiceFacade.validate_spy_gs_authority(employeeConfigDto, companyAuthorityDtoList); | |
| 310 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 311 | + } catch (PlanModuleException exp) { | |
| 312 | + rtn.put("status", ResponseCode.ERROR); | |
| 313 | + rtn.put("msg", exp.getMessage()); | |
| 314 | + } | |
| 315 | + return rtn; | |
| 316 | + } | |
| 317 | + | |
| 318 | + @RequestMapping(value = "/validate_spy_fgs", method = RequestMethod.GET) | |
| 319 | + public Map<String, Object> validate_spy_fgs(HttpServletRequest request, @RequestParam Map<String, Object> param) { | |
| 320 | + HttpSession session = request.getSession(); | |
| 321 | + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | |
| 322 | + List<CompanyAuthorityDto> companyAuthorityDtoList = new ArrayList<>(); | |
| 323 | + for (CompanyAuthority companyAuthority : cmyAuths) { | |
| 324 | + CompanyAuthorityDto companyAuthorityDto = CompanyAuthorityDto.getBuilder() | |
| 325 | + .setId(companyAuthority.getId()) | |
| 326 | + .setCompanyCode(companyAuthority.getCompanyCode()) | |
| 327 | + .setCompanyName(companyAuthority.getCompanyName()) | |
| 328 | + .setSubCompanyCode(companyAuthority.getSubCompanyCode()) | |
| 329 | + .setSubCompanyName(companyAuthority.getSubCompanyName()) | |
| 330 | + .build(); | |
| 331 | + companyAuthorityDtoList.add(companyAuthorityDto); | |
| 332 | + } | |
| 333 | + | |
| 334 | + Map<String, Object> rtn = new HashMap<>(); | |
| 335 | + try { | |
| 336 | + EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 337 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 338 | + LineDto.getBuilder() | |
| 339 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 340 | + .setName(param.get("xl.name_eq").toString()) | |
| 341 | + .build() | |
| 342 | + )) | |
| 343 | + .setSpy(param.get("spy.id_eq") == null ? null : ( | |
| 344 | + PersonnelDto.getBuilder() | |
| 345 | + .setId(Integer.valueOf(param.get("spy.id_eq").toString())) | |
| 346 | + .build() | |
| 347 | + )) | |
| 348 | + .build(); | |
| 349 | + employeeConfigServiceFacade.validate_spy_fgs_authority(employeeConfigDto, companyAuthorityDtoList); | |
| 350 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 351 | + } catch (PlanModuleException exp) { | |
| 352 | + rtn.put("status", ResponseCode.ERROR); | |
| 353 | + rtn.put("msg", exp.getMessage()); | |
| 354 | + } | |
| 355 | + return rtn; | |
| 356 | + } | |
| 357 | + | |
| 358 | + //------------------ TODO:导入导出逻辑,之后会服务化 -----------------// | |
| 359 | + @Autowired | |
| 360 | + private EmployeeConfigInfoService employeeConfigInfoService; | |
| 361 | + // 上传excel文件 | |
| 362 | + @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) | |
| 363 | + public Map<String, Object> uploadFile(MultipartFile file) { | |
| 364 | + Map<String, Object> rtn = new HashMap<>(); | |
| 365 | + try { | |
| 366 | + DataToolsFile dataToolsFile = employeeConfigInfoService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 367 | + // excel文件名 | |
| 368 | + String fileName = dataToolsFile.getFile().getAbsolutePath(); | |
| 369 | + Workbook wb = dataToolsFile.getFileType().getWorkBook(dataToolsFile.getFile()); | |
| 370 | + | |
| 371 | + // excel文件sheet | |
| 372 | + List<String> sheetnames = new ArrayList<>(); | |
| 373 | + for (int i = 0; i < wb.getNumberOfSheets(); i ++) { | |
| 374 | + sheetnames.add(wb.getSheetAt(i).getSheetName()); | |
| 375 | + } | |
| 376 | + | |
| 377 | + wb.close(); | |
| 378 | + | |
| 379 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 380 | + rtn.put("filename", fileName); | |
| 381 | + rtn.put("sheetnames", StringUtils.join(sheetnames, ",")); | |
| 382 | + } catch (Exception exp) { | |
| 383 | + exp.printStackTrace(); | |
| 384 | + rtn.put("status", ResponseCode.ERROR); | |
| 385 | + rtn.put("msg", exp.getMessage()); | |
| 386 | + } | |
| 387 | + return rtn; | |
| 388 | + } | |
| 389 | + // 导入excel文件 | |
| 390 | + @RequestMapping(value = "/importFile", method = RequestMethod.POST) | |
| 391 | + public Map<String, Object> importFile(@RequestParam Map<String, Object> params) { | |
| 392 | + Map<String, Object> rtn = new HashMap<>(); | |
| 393 | + | |
| 394 | + try { | |
| 395 | + File file = new File(String.valueOf(params.get("filename"))); | |
| 396 | + if (!file.exists()) { | |
| 397 | + throw new Exception("导入文件不存在!"); | |
| 398 | + } | |
| 399 | + employeeConfigInfoService.importData(file, params); | |
| 400 | + | |
| 401 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 402 | + rtn.put("msg", "导入文件成功"); | |
| 403 | + } catch (Exception exp) { | |
| 404 | + rtn.put("status", ResponseCode.ERROR); | |
| 405 | + rtn.put("msg", exp.getMessage()); | |
| 406 | + } | |
| 407 | + | |
| 408 | + return rtn; | |
| 409 | + } | |
| 410 | + // 上传并导入excel文件 | |
| 411 | + @RequestMapping(value = "/uploadAndImportFile", method = RequestMethod.POST) | |
| 412 | + public Map<String, Object> uploadAndImportFile(MultipartFile file) { | |
| 413 | + Map<String, Object> rtn = new HashMap<>(); | |
| 414 | + | |
| 415 | + try { | |
| 416 | + DataToolsFile dataToolsFile = employeeConfigInfoService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 417 | + Map<String, Object> params = new HashMap<>(); | |
| 418 | + employeeConfigInfoService.importData(dataToolsFile.getFile(), params); | |
| 419 | + | |
| 420 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 421 | + rtn.put("msg", "上传&导入文件成功"); | |
| 422 | + } catch (Exception exp) { | |
| 423 | + exp.printStackTrace(); | |
| 424 | + rtn.put("status", ResponseCode.ERROR); | |
| 425 | + rtn.put("msg", exp.getMessage()); | |
| 426 | + } | |
| 427 | + | |
| 428 | + return rtn; | |
| 429 | + } | |
| 430 | + | |
| 431 | + // 导出数据到xls文件 | |
| 432 | + @RequestMapping(value = "/exportFile", method = RequestMethod.GET) | |
| 433 | + public void exportFile(HttpServletResponse response, | |
| 434 | + @RequestParam Map<String, Object> params) throws Exception { | |
| 435 | + DataToolsFile dataToolsFile = employeeConfigInfoService.exportData(params); | |
| 436 | + // 流输出导出文件 | |
| 437 | + response.setHeader("content-type", "application/octet-stream"); | |
| 438 | + response.setHeader("Content-Disposition", "attachment; filename=" + dataToolsFile.getFile().getName()); | |
| 439 | + response.setContentType("application/octet-stream"); | |
| 440 | + | |
| 441 | + OutputStream os = response.getOutputStream(); | |
| 442 | + BufferedOutputStream bos = new BufferedOutputStream(os); | |
| 443 | + | |
| 444 | + InputStream is = new FileInputStream(dataToolsFile.getFile()); | |
| 445 | + BufferedInputStream bis = new BufferedInputStream(is); | |
| 446 | + | |
| 447 | + int length = 0; | |
| 448 | + byte[] temp = new byte[1 * 1024 * 10]; | |
| 449 | + while ((length = bis.read(temp)) != -1) { | |
| 450 | + bos.write(temp, 0, length); | |
| 451 | + } | |
| 452 | + bos.flush(); | |
| 453 | + bis.close(); | |
| 454 | + bos.close(); | |
| 455 | + is.close(); | |
| 456 | + } | |
| 457 | + | |
| 458 | + | |
| 459 | +} | ... | ... |
src/main/java/com/bsth/controller/schedule/core/EmployeeConfigInfoController.java renamed to src/main/java/com/bsth/controller/schedule/core/legacy/EmployeeConfigInfoController.java
| 1 | -package com.bsth.controller.schedule.core; | |
| 1 | +package com.bsth.controller.schedule.core.legacy; | |
| 2 | 2 | |
| 3 | 3 | import com.bsth.common.Constants; |
| 4 | 4 | import com.bsth.common.ResponseCode; |
| ... | ... | @@ -20,8 +20,8 @@ import java.util.Map; |
| 20 | 20 | /** |
| 21 | 21 | * Created by xu on 16/5/10. |
| 22 | 22 | */ |
| 23 | -@RestController | |
| 24 | -@RequestMapping("eci") | |
| 23 | +//@RestController | |
| 24 | +//@RequestMapping("eci") | |
| 25 | 25 | public class EmployeeConfigInfoController extends BController<EmployeeConfigInfo, Long> { |
| 26 | 26 | @Autowired |
| 27 | 27 | private EmployeeConfigInfoRepository employeeConfigInfoRepository; | ... | ... |
src/main/resources/dubbo/applicationContext_dubbo_consumer.xml
| ... | ... | @@ -21,6 +21,8 @@ |
| 21 | 21 | |
| 22 | 22 | <!-- 车辆配置信息服务 --> |
| 23 | 23 | <dubbo:reference interface="com.bsth.control_v2.plan_module.common.service.schedule.config.VehicleConfigServiceFacade" id="vehicleConfigServiceFacadeImpl" check="false" /> |
| 24 | + <!-- 人员配置信息服务 --> | |
| 25 | + <dubbo:reference interface="com.bsth.control_v2.plan_module.common.service.schedule.config.EmployeeConfigServiceFacade" id="employeeConfigServiceFacadeImpl" check="false" /> | |
| 24 | 26 | |
| 25 | 27 | <!-- 时刻表班型明细服务 --> |
| 26 | 28 | <dubbo:reference interface="com.bsth.control_v2.plan_module.common.service.schedule.timetable.TTInfoBxDetailServiceFacade" id="tTInfoBxDetailServiceFacadeImpl" check="false" /> | ... | ... |