|
|
@ -8,16 +8,23 @@ import com.epmet.commons.tools.constant.AppClientConstant; |
|
|
|
import com.epmet.commons.tools.enums.RequirePermissionEnum; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.service.StaffService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.io.IOUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
@ -25,6 +32,7 @@ import java.util.List; |
|
|
|
* @author zhaoqifeng |
|
|
|
* @date 2020/4/23 17:59 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@RestController |
|
|
|
@RequestMapping("staff") |
|
|
|
public class StaffController { |
|
|
@ -251,4 +259,34 @@ public class StaffController { |
|
|
|
return new Result<List<StaffOrgListResultDTO>>().ok(staffService.staffOrgList(tokenDto)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 下载工作人员导入excel模板 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping("import/download-template") |
|
|
|
public void downloadIcResiDownloadTemplate(HttpServletResponse response) { |
|
|
|
InputStream is = null; |
|
|
|
ServletOutputStream os = null; |
|
|
|
try { |
|
|
|
os = response.getOutputStream(); |
|
|
|
|
|
|
|
is = this.getClass().getClassLoader().getResourceAsStream("excel/customer_staff_import_template.xlsx"); |
|
|
|
|
|
|
|
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); |
|
|
|
response.setHeader("content-Type", "application/vnd.ms-excel"); |
|
|
|
response.setHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode("工作人员导入模板.xlsx", "UTF-8")); |
|
|
|
|
|
|
|
IOUtils.copy(is, os); |
|
|
|
} catch (Exception e) { |
|
|
|
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); |
|
|
|
log.error("下载工作人员导入模板失败:{}", errorStackTrace); |
|
|
|
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "下载工作人员导入模板失败"); |
|
|
|
} finally { |
|
|
|
org.apache.poi.util.IOUtils.closeQuietly(is); |
|
|
|
org.apache.poi.util.IOUtils.closeQuietly(os); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|