Search in sources :

Example 1 with CustomerserviceWagesDTO

use of com.github.lybgeek.modules.customerservice.dto.CustomerserviceWagesDTO in project springboot-learning by lyb-geek.

the class CustomerserviceWagesController method exportExcelTemplate.

/**
 * 本方法用到的模板是为于excel-template下的工资表模板.xls
 * @throws Exception
 */
@GetMapping(value = "/exportTemplate")
public void exportExcelTemplate() throws Exception {
    List<CustomerserviceWagesDTO> customerserviceWagesDTOS = customerserviceWagesService.listCustomerserviceWages();
    String templateFileName = SystemUtils.getBaseExcelTemplatePath() + CustomerserviceWagesConstant.EXCEL_TEMPLATE;
    Map<String, Object> templateParamsMap = new HashMap<>();
    String company = "天下财团";
    String date = DateUtils.format(new Date(), "yyyy年MM月");
    templateParamsMap.put("company", company);
    templateParamsMap.put("date", date);
    ExcelWriter.builder().response(response).fileName(company + date + "工资表").templateParamsMap(templateParamsMap).build().writeTemplate(templateFileName, customerserviceWagesDTOS);
}
Also used : HashMap(java.util.HashMap) CustomerserviceWagesDTO(com.github.lybgeek.modules.customerservice.dto.CustomerserviceWagesDTO) Date(java.util.Date) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with CustomerserviceWagesDTO

use of com.github.lybgeek.modules.customerservice.dto.CustomerserviceWagesDTO in project springboot-learning by lyb-geek.

the class CustomerserviceWagesController method importExcel.

/**
 * 本方法用的模板是位于excel-template下的-->复杂表头样例.xls
 * @param file
 * @return
 * @throws Exception
 */
@PostMapping(value = "/import")
@ResponseBody
public Result<CustomerserviceWagesDTO> importExcel(MultipartFile file) throws Exception {
    ExcelImportResult<CustomerserviceWagesVO> excelData = ExcelReader.builder().titleRows(1).headRowNumber(2).sheetNo(0).inputStream(file.getInputStream()).build().read(CustomerserviceWagesVO.class, true);
    boolean verifyFail = excelData.isVerifyFail();
    if (verifyFail) {
        String errorMsg = ExcelUtils.getErrorMsg(excelData.getFailList());
        throw new BizException(errorMsg);
    }
    List<CustomerserviceWagesDTO> customerserviceWagesDTOS = customerserviceWagesConverter.convertVOList2DTOList(excelData.getList());
    customerserviceWagesService.saveCustomerserviceWages(customerserviceWagesDTOS);
    Result result = new Result().builder().data(customerserviceWagesDTOS).build();
    return result;
}
Also used : CustomerserviceWagesVO(com.github.lybgeek.modules.customerservice.vo.CustomerserviceWagesVO) BizException(com.github.lybgeek.common.exception.BizException) CustomerserviceWagesDTO(com.github.lybgeek.modules.customerservice.dto.CustomerserviceWagesDTO) Result(com.github.lybgeek.common.model.Result) ExcelImportResult(cn.afterturn.easypoi.excel.entity.result.ExcelImportResult) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

CustomerserviceWagesDTO (com.github.lybgeek.modules.customerservice.dto.CustomerserviceWagesDTO)2 ExcelImportResult (cn.afterturn.easypoi.excel.entity.result.ExcelImportResult)1 BizException (com.github.lybgeek.common.exception.BizException)1 Result (com.github.lybgeek.common.model.Result)1 CustomerserviceWagesVO (com.github.lybgeek.modules.customerservice.vo.CustomerserviceWagesVO)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1