Commit 6c9d2a9d authored by lisong's avatar lisong

修改光伏导入、导出、模板

parent 13f5d1ee
......@@ -7,43 +7,43 @@ import lombok.Data;
@Data
public class HouseholdPvImport {
@ColumnWidth(15)
@ExcelProperty(value = "所属场站", index = 0)
@ExcelProperty(value = "所属场站", index = 1)
private String platformCompanyId;
@ColumnWidth(15)
@ExcelProperty(value = "乡镇", index = 1)
@ExcelProperty(value = "乡镇", index = 2)
private String districtId;
@ColumnWidth(15)
@ExcelProperty(value = "户号", index = 2)
@ExcelProperty(value = "户号", index = 3)
private String number;
@ColumnWidth(15)
@ExcelProperty(value = "户主姓名", index = 3)
@ExcelProperty(value = "户主姓名", index = 4)
private String name;
@ColumnWidth(15)
@ExcelProperty(value = "性别", index = 4)
@ExcelProperty(value = "性别", index = 5)
private String sex;
@ColumnWidth(15)
@ExcelProperty(value = "身份证号", index = 5)
@ExcelProperty(value = "身份证号", index = 6)
private String idNumber;
@ColumnWidth(20)
@ExcelProperty(value = "证件过期时间", index = 6)
@ExcelProperty(value = "证件过期时间", index = 7)
private String expiryTime;
@ColumnWidth(15)
@ExcelProperty(value = "签发机关", index = 7)
@ExcelProperty(value = "签发机关", index = 8)
private String issuingAuthority;
@ColumnWidth(15)
@ExcelProperty(value = "户籍地址", index = 8)
@ExcelProperty(value = "户籍地址", index = 9)
private String residenceAddress;
@ColumnWidth(15)
@ExcelProperty(value = "手机号码", index = 9)
@ExcelProperty(value = "手机号码", index = 10)
private String phone;
@ColumnWidth(15)
@ExcelProperty(value = "居住地", index = 10)
@ExcelProperty(value = "居住地", index = 11)
private String address;
@ColumnWidth(15)
@ExcelProperty(value = "居住地邮编", index = 11)
@ExcelProperty(value = "居住地邮编", index = 12)
private String postcode;
@ColumnWidth(15)
@ExcelProperty(value = "送达地址", index = 12)
@ExcelProperty(value = "送达地址", index = 13)
private String serviceAddress;
......
......@@ -19,6 +19,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.HouseholdPvServiceImp
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
......@@ -156,7 +157,7 @@ public class HouseholdPvController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "模板下载", notes = "模板下载")
public void exportTemplates(HttpServletResponse response) {
FileUtil.downloadResource("户用光伏导入模板.xlsx", "templates/householdTemplates.xls", response);
FileUtil.downloadResource("户用光伏导入模板.xlsx", "templates/householdTemplatesNew.xls", response);
}
......@@ -176,7 +177,7 @@ public class HouseholdPvController extends BaseController {
@GetMapping(value = "/exportData")
@GetMapping(value = "/exportDataOld")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "数据导出", notes = "数据导出")
public void exportMessage(HttpServletResponse response, HouseholdPvDto dto) throws IOException {
......@@ -231,7 +232,48 @@ public class HouseholdPvController extends BaseController {
}
}
@GetMapping(value = "/exportData")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "数据导出", notes = "数据导出")
public void exportMessageNew(HttpServletResponse response, HouseholdPvDto dto) throws IOException {
try {
ClassPathResource cpr = new ClassPathResource("templates/householdExportNew.xls");
InputStream is = cpr.getInputStream();
Workbook workbook = new XSSFWorkbook(is);
Sheet sheet = workbook.getSheetAt(0);
List<HouseholdPvExport> list = iHouseholdPvService.selectExportList(dto, dto.getIds());
// 序号
int num = 1;
for (HouseholdPvExport item : list) {
// 获取当前插入数据行号
int lastRowNum = sheet.getLastRowNum() + 1;
Row row = sheet.createRow((short) (lastRowNum));
row.createCell(0).setCellValue(num);
num++;
row.createCell(1).setCellValue(ObjectUtils.isEmpty(item.getNumber()) ? "" : item.getNumber());
row.createCell(2).setCellValue(ObjectUtils.isEmpty(item.getName()) ? "" : item.getName());
row.createCell(3).setCellValue(ObjectUtils.isEmpty(item.getIdNumber()) ? "" : item.getIdNumber());
row.createCell(4).setCellValue(ObjectUtils.isEmpty(item.getPhone()) ? "" : item.getPhone());
row.createCell(5).setCellValue(ObjectUtils.isEmpty(item.getInstallAddress()) ? "" : item.getInstallAddress());
// 安装总功率
if (!ObjectUtils.isEmpty(item)&& !ObjectUtils.isEmpty(item.getActualCapacity()) && !ObjectUtils.isEmpty(item.getInstallCount())) {
row.createCell(6).setCellValue(Math.multiplyExact(Long.valueOf(item.getActualCapacity()),Long.valueOf(item.getInstallCount())));
} else {
row.createCell(6).setCellValue(0);
}
row.createCell(7).setCellValue(ObjectUtils.isEmpty(item.getContactNumber()) ? "" : item.getContactNumber());
row.createCell(8).setCellValue(ObjectUtils.isEmpty(item.getGenerationNumber()) ? "" : item.getGenerationNumber());
row.createCell(9).setCellValue(ObjectUtils.isEmpty(item.getInverterSerialNumber()) ? "" : item.getInverterSerialNumber());
}
response.setCharacterEncoding("UTF-8");
response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Content-Disposition",
"attachment;filename=\"" + URLEncoder.encode("户用光伏信息.xls", "UTF-8") + "\"");
workbook.write(response.getOutputStream());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/deleteBatch")
@ApiOperation(httpMethod = "POST", value = "批量删除", notes = "批量删除")
......
......@@ -176,9 +176,9 @@ public class HouseholdPvServiceImpl extends BaseService<HouseholdPvDto, Househol
if (ObjectUtils.isEmpty(dto.getPostcode())) {
return "第 " + line + " 行居住地邮编不能为空!";
}
if (ObjectUtils.isEmpty(dto.getServiceAddress())) {
return "第 " + line + " 行送达地址不能为空!";
}
// if (ObjectUtils.isEmpty(dto.getServiceAddress())) {
// return "第 " + line + " 行送达地址不能为空!";
// }
// 导入文件中数据校验
List<HouseholdPvImport> collect = list.stream().filter(item -> dto.getNumber().equals(item.getNumber())).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(collect) && collect.size() >= 2) {
......@@ -220,9 +220,9 @@ public class HouseholdPvServiceImpl extends BaseService<HouseholdPvDto, Househol
if (dto.getPostcode().length() > 10) {
return "第" + line + " 行居住地邮编最多输入10个字符!";
}
if (dto.getServiceAddress().length() > 200) {
return "第" + line + " 行送达地址最多输入200个字符!";
}
// if (dto.getServiceAddress().length() > 200) {
// return "第" + line + " 行送达地址最多输入200个字符!";
// }
if (dto.getResidenceAddress().length() > 400) {
return "第" + line + " 户籍地址最多输入400个字符!";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment