|
|
@ -17,7 +17,12 @@ |
|
|
|
|
|
|
|
package com.epmet.controller; |
|
|
|
|
|
|
|
import cn.afterturn.easypoi.excel.ExcelExportUtil; |
|
|
|
import cn.afterturn.easypoi.excel.entity.ExportParams; |
|
|
|
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; |
|
|
|
import com.epmet.commons.tools.annotation.LoginUser; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ExcelUtils; |
|
|
@ -25,19 +30,22 @@ import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.validator.AssertUtils; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.epmet.commons.tools.validator.group.AddGroup; |
|
|
|
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|
|
|
import com.epmet.commons.tools.validator.group.DefaultGroup; |
|
|
|
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|
|
|
import com.epmet.dto.IcResiUserDTO; |
|
|
|
import com.epmet.dto.UserResiInfoDTO; |
|
|
|
import com.epmet.dto.form.CustomerFormQueryDTO; |
|
|
|
import com.epmet.dto.form.IcResiUserFormDTO; |
|
|
|
import com.epmet.dto.result.CheckFloatFootBarResultDTO; |
|
|
|
import com.epmet.excel.IcResiUserExcel; |
|
|
|
import com.epmet.feign.OperCustomizeOpenFeignClient; |
|
|
|
import com.epmet.service.IcResiUserService; |
|
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
@ -50,6 +58,8 @@ import java.util.Map; |
|
|
|
@RequestMapping("icresiuser") |
|
|
|
public class IcResiUserController { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private OperCustomizeOpenFeignClient operCustomizeOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private IcResiUserService icResiUserService; |
|
|
|
|
|
|
@ -115,4 +125,40 @@ public class IcResiUserController { |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("download/template") |
|
|
|
public void downloadTemplate(@RequestParam String customerId) throws Exception { |
|
|
|
CustomerFormQueryDTO queryDTO = new CustomerFormQueryDTO(); |
|
|
|
queryDTO.setFormCode("resi_base_info"); |
|
|
|
queryDTO.setCustomerId(customerId); |
|
|
|
|
|
|
|
Result<CheckFloatFootBarResultDTO> resultForm = operCustomizeOpenFeignClient.getCustomerForm(queryDTO); |
|
|
|
if (resultForm == null || !resultForm.success()) ||resultForm.getData() == null){ |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} |
|
|
|
List<ExcelExportEntity> colList = new ArrayList<>(); |
|
|
|
|
|
|
|
ExcelExportEntity desginGroup = new ExcelExportEntity("表头名称","键"); |
|
|
|
desginGroup.setNeedMerge(true); |
|
|
|
List<ExcelExportEntity> paramCols = new ArrayList<>(); |
|
|
|
List<String> headerList = Arrays.asList("头1","头2","头3"); |
|
|
|
headerList.forEach(e->{ |
|
|
|
paramCols.add(new ExcelExportEntity(e,e,30)); |
|
|
|
}); |
|
|
|
|
|
|
|
desginGroup.setList(paramCols); |
|
|
|
colList.add(desginGroup); |
|
|
|
List<Map<String, String>> dataList =new ArrayList<>(); |
|
|
|
Map<String,String> dataMap = new HashMap<>(); |
|
|
|
dataMap.put("头1","1"); |
|
|
|
dataMap.put("头2","2"); |
|
|
|
dataMap.put("头3","3"); |
|
|
|
dataList.add(dataMap); |
|
|
|
ExportParams entity = new ExportParams(); |
|
|
|
Workbook workbook = ExcelExportUtil.exportExcel(entity, colList, dataList); |
|
|
|
//ExcelExportUtil.exportExcel
|
|
|
|
FileOutputStream fos = new FileOutputStream("//Users/liujianjun/Downloads/基础信息表/Dow.tt.xls"); |
|
|
|
workbook.write(fos); |
|
|
|
fos.close(); |
|
|
|
} |
|
|
|
|
|
|
|
} |