| | |
| | | package com.vci.frameworkcore.controller; |
| | | |
| | | import com.vci.frameworkcore.compatibility.SmUserQueryServiceI; |
| | | import com.vci.frameworkcore.constant.FrameWorkLangCodeConstant; |
| | | import com.vci.frameworkcore.model.dto.SmUserDTO; |
| | | import com.vci.frameworkcore.pagemodel.SmUserVO; |
| | | import com.vci.starter.web.annotation.controller.VciUnCheckRight; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.*; |
| | | import com.vci.starter.web.util.ControllerUtil; |
| | | import com.vci.starter.web.util.LangBaseUtil; |
| | | import com.vci.starter.web.util.LocalFileUtil; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * 下载人员导入模板 |
| | | * @param downloadFileName |
| | | * @param response |
| | | */ |
| | | @RequestMapping(value = "/downloadImportTemplate",method = RequestMethod.POST) |
| | | public void downloadImportTemplate(){ |
| | | |
| | | @RequestMapping(value = "/downloadImportTemplate",method = RequestMethod.GET) |
| | | @VciUnCheckRight |
| | | public void downloadImportTemplate(String downloadFileName, HttpServletResponse response){ |
| | | String excelPath = userQueryService.downloadImportTemplate(downloadFileName); |
| | | try { |
| | | ControllerUtil.writeFileToResponse(response,excelPath); |
| | | } catch (IOException e) { |
| | | String msg = "下载用户导入模板时出现错误,原因:" + LangBaseUtil.getErrorMsg(e); |
| | | try { |
| | | e.printStackTrace(); |
| | | ControllerUtil.writeDataToResponse(response, StringUtils.isNotBlank(msg)?msg.getBytes():new byte[0],null); |
| | | } catch (IOException ioException) { |
| | | ioException.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 人员导入 |
| | | */ |
| | | @RequestMapping(value = "/importUser",method = RequestMethod.POST) |
| | | public void importUser(){ |
| | | |
| | | @VciUnCheckRight |
| | | public BaseResult importUser(MultipartFile file){ |
| | | String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + LocalFileUtil.getFileNameForIE(file.getOriginalFilename()); |
| | | File file1 = new File(excelFileName); |
| | | try { |
| | | file.transferTo(new File(excelFileName)); |
| | | if (file != null) { |
| | | return userQueryService.importUser(file1); |
| | | } else { |
| | | return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"无导入的文件"}); |
| | | } |
| | | }catch (Throwable e) { |
| | | throw new VciBaseException(e.getMessage(),new String[0],e); |
| | | }finally { |
| | | file1.delete(); |
| | | } |
| | | } |
| | | |
| | | } |