Commit 2afdc84f authored by lisong's avatar lisong

修改户用光伏导出、下载模板

parent f2a97230
package com.yeejoin.amos.boot.module.jxiop.api.dto;
import lombok.Data;
@Data
public class EquipMessageExport {
private Integer numSort;
private String name;
private String idNumber;
private String type;
private String equipName;
private String brand;
private String snCode;
private String description;
}
package com.yeejoin.amos.boot.module.jxiop.api.mapper; package com.yeejoin.amos.boot.module.jxiop.api.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.dto.EquipMessageExport;
import com.yeejoin.amos.boot.module.jxiop.api.dto.HouseholdPvDeviceDto; import com.yeejoin.amos.boot.module.jxiop.api.dto.HouseholdPvDeviceDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.HouseholdPvDto; import com.yeejoin.amos.boot.module.jxiop.api.dto.HouseholdPvDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.HouseholdPvExport; import com.yeejoin.amos.boot.module.jxiop.api.dto.HouseholdPvExport;
...@@ -21,6 +22,8 @@ public interface HouseholdPvMapper extends BaseMapper<HouseholdPv> { ...@@ -21,6 +22,8 @@ public interface HouseholdPvMapper extends BaseMapper<HouseholdPv> {
List<HouseholdPvExport> selectExportList(@Param("dto")HouseholdPvDto dto, @Param("ids") List<Long> ids); List<HouseholdPvExport> selectExportList(@Param("dto")HouseholdPvDto dto, @Param("ids") List<Long> ids);
List<EquipMessageExport> selectExportEquipMessage(@Param("dto")HouseholdPvDto dto, @Param("ids") List<Long> ids);
List<HouseholdPvDeviceDto> selectEquipList(@Param("id")Long id ); List<HouseholdPvDeviceDto> selectEquipList(@Param("id")Long id );
......
...@@ -5,10 +5,7 @@ import java.util.List; ...@@ -5,10 +5,7 @@ import java.util.List;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yeejoin.amos.boot.module.jxiop.api.dto.CompanyTreeDto; import com.yeejoin.amos.boot.module.jxiop.api.dto.*;
import com.yeejoin.amos.boot.module.jxiop.api.dto.HouseholdPvDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.HouseholdPvExport;
import com.yeejoin.amos.boot.module.jxiop.api.dto.HouseholdPvImport;
import com.yeejoin.amos.boot.module.jxiop.api.entity.HouseholdPv; import com.yeejoin.amos.boot.module.jxiop.api.entity.HouseholdPv;
import com.yeejoin.amos.boot.module.jxiop.api.util.CommonResponse; import com.yeejoin.amos.boot.module.jxiop.api.util.CommonResponse;
import com.yeejoin.amos.feign.privilege.model.UserOrgTreeModel; import com.yeejoin.amos.feign.privilege.model.UserOrgTreeModel;
...@@ -34,4 +31,14 @@ public interface IHouseholdPvService extends IService<HouseholdPv>{ ...@@ -34,4 +31,14 @@ public interface IHouseholdPvService extends IService<HouseholdPv>{
HouseholdPvDto getBySeq(Long id); HouseholdPvDto getBySeq(Long id);
Integer countRepeat(HouseholdPvDto householdPvDto, String type); Integer countRepeat(HouseholdPvDto householdPvDto, String type);
/**
* 导出-户用光伏运维表-设备信息
* @param dto
* @param ids
* @return
*/
List<EquipMessageExport> selectExportEquipMessage(HouseholdPvDto dto, List<Long> ids);
} }
...@@ -97,5 +97,42 @@ ...@@ -97,5 +97,42 @@
WHERE WHERE
sequence_nbr = #{id} sequence_nbr = #{id}
</select> </select>
<select id="selectExportEquipMessage"
resultType="com.yeejoin.amos.boot.module.jxiop.api.dto.EquipMessageExport">
SELECT
(@i:= @i+1) as numSort,
hp.`name`,
hp.ID_number AS idNumber,
hpd.type,
hpd.name as equipName,
hpd.brand,
hpd.SN_code as snCode,
hpd.SN_code as description
FROM
(SELECT @i:=0) as i,
household_pv hp
left join household_pv_device hpd on hp.sequence_nbr = hpd.household_pv_id
<where>
<if test="dto.name != null and dto.name != ''">
and hp.name like concat('%',#{dto.name},'%')
</if>
<if test="dto.bizOrgCode != null and dto.bizOrgCode != ''">
and hp.biz_org_code like concat('%',#{dto.bizOrgCode},'%')
</if>
<if test="dto.level != null and dto.level != ''">
and hp.level = #{dto.level}
</if>
<if test="dto.number != null and dto.number != ''">
and hp.number like concat('%',#{dto.number},'%')
</if>
<if test="ids != null and ids.size > 0">
and hp.sequence_nbr in
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
</mapper> </mapper>
package com.yeejoin.amos.boot.module.jxiop.biz.controller; package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil; import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
import com.yeejoin.amos.boot.module.jxiop.api.dto.EquipMessageExport;
import com.yeejoin.amos.boot.module.jxiop.api.dto.HouseholdPvDto; import com.yeejoin.amos.boot.module.jxiop.api.dto.HouseholdPvDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.HouseholdPvExport; import com.yeejoin.amos.boot.module.jxiop.api.dto.HouseholdPvExport;
import com.yeejoin.amos.boot.module.jxiop.api.dto.HouseholdPvImport; import com.yeejoin.amos.boot.module.jxiop.api.dto.HouseholdPvImport;
import com.yeejoin.amos.boot.module.jxiop.api.entity.HouseholdPv;
import com.yeejoin.amos.boot.module.jxiop.api.service.IHouseholdPvService; import com.yeejoin.amos.boot.module.jxiop.api.service.IHouseholdPvService;
import com.yeejoin.amos.boot.module.jxiop.api.util.CommonResponse; import com.yeejoin.amos.boot.module.jxiop.api.util.CommonResponse;
import com.yeejoin.amos.boot.module.jxiop.api.util.CommonResponseUtil; import com.yeejoin.amos.boot.module.jxiop.api.util.CommonResponseUtil;
...@@ -19,7 +17,6 @@ import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.HouseholdPvServiceImp ...@@ -19,7 +17,6 @@ import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.HouseholdPvServiceImp
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.ObjectUtils; 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.Row;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
...@@ -40,8 +37,6 @@ import java.io.IOException; ...@@ -40,8 +37,6 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* 户用光伏表 * 户用光伏表
...@@ -157,7 +152,7 @@ public class HouseholdPvController extends BaseController { ...@@ -157,7 +152,7 @@ public class HouseholdPvController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "模板下载", notes = "模板下载") @ApiOperation(httpMethod = "GET", value = "模板下载", notes = "模板下载")
public void exportTemplates(HttpServletResponse response) { public void exportTemplates(HttpServletResponse response) {
FileUtil.downloadResource("户用光伏导入模板.xlsx", "templates/householdTemplatesNew.xls", response); FileUtil.downloadResource("户用光伏导入模板.xlsx", "templates/householdTemplates.xls", response);
} }
...@@ -232,6 +227,12 @@ public class HouseholdPvController extends BaseController { ...@@ -232,6 +227,12 @@ public class HouseholdPvController extends BaseController {
} }
} }
/**
* 验收信息
* @param response
* @param dto
* @throws IOException
*/
@GetMapping(value = "/exportData") @GetMapping(value = "/exportData")
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "数据导出", notes = "数据导出") @ApiOperation(httpMethod = "GET", value = "数据导出", notes = "数据导出")
...@@ -257,7 +258,8 @@ public class HouseholdPvController extends BaseController { ...@@ -257,7 +258,8 @@ public class HouseholdPvController extends BaseController {
row.createCell(5).setCellValue(ObjectUtils.isEmpty(item.getInstallAddress()) ? "" : item.getInstallAddress()); row.createCell(5).setCellValue(ObjectUtils.isEmpty(item.getInstallAddress()) ? "" : item.getInstallAddress());
// 安装总功率 // 安装总功率
if (!ObjectUtils.isEmpty(item)&& !ObjectUtils.isEmpty(item.getActualCapacity()) && !ObjectUtils.isEmpty(item.getInstallCount())) { 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()))); long multiplyExact = Math.multiplyExact(Long.parseLong(item.getActualCapacity()), Long.parseLong(item.getInstallCount()));
row.createCell(6).setCellValue(String.valueOf(multiplyExact));
} else { } else {
row.createCell(6).setCellValue(0); row.createCell(6).setCellValue(0);
} }
...@@ -268,7 +270,110 @@ public class HouseholdPvController extends BaseController { ...@@ -268,7 +270,110 @@ public class HouseholdPvController extends BaseController {
response.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8");
response.setHeader("content-Type", "application/vnd.ms-excel"); response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Content-Disposition", response.setHeader("Content-Disposition",
"attachment;filename=\"" + URLEncoder.encode("户用光伏信息.xls", "UTF-8") + "\""); "attachment;filename=\"" + URLEncoder.encode("户用光伏验收表.xls", "UTF-8") + "\"");
workbook.write(response.getOutputStream());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
/**
* 导出户用光伏运维信息(基本信息、合同信息、设备信息、租赁物信息)
* @param response
* @param dto
* @throws IOException
*/
@GetMapping(value = "/exportDataAll")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "数据导出", notes = "数据导出")
public void exportMessageAll(HttpServletResponse response, HouseholdPvDto dto) throws IOException {
try {
ClassPathResource cpr = new ClassPathResource("templates/householdExportAll.xls");
InputStream is = cpr.getInputStream();
Workbook workbook = new XSSFWorkbook(is);
// 基础信息
Sheet sheet = workbook.getSheetAt(0);
Sheet contactSheet = workbook.getSheetAt(1);
Sheet equipSheet = workbook.getSheetAt(2);
Sheet leaseSheet = workbook.getSheetAt(3);
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.getPlatformCompanyId()) ? "" : item.getPlatformCompanyId());
row.createCell(2).setCellValue(ObjectUtils.isEmpty(item.getDistrictId()) ? "" : item.getDistrictId());
row.createCell(3).setCellValue(ObjectUtils.isEmpty(item.getNumber()) ? "" : item.getNumber());
row.createCell(4).setCellValue(ObjectUtils.isEmpty(item.getName()) ? "" : item.getName());
row.createCell(5).setCellValue(ObjectUtils.isEmpty(item.getSex()) ? "" : item.getSex());
row.createCell(6).setCellValue(ObjectUtils.isEmpty(item.getIdNumber()) ? "" : item.getIdNumber());
row.createCell(7).setCellValue(ObjectUtils.isEmpty(item.getExpiryTime()) ? "" : item.getExpiryTime());
row.createCell(8).setCellValue(ObjectUtils.isEmpty(item.getIssuingAuthority()) ? "" : item.getIssuingAuthority());
row.createCell(9).setCellValue(ObjectUtils.isEmpty(item.getResidenceAddress()) ? "" : item.getResidenceAddress());
row.createCell(10).setCellValue(ObjectUtils.isEmpty(item.getPhone()) ? "" : item.getPhone());
row.createCell(11).setCellValue(ObjectUtils.isEmpty(item.getAddress()) ? "" : item.getAddress());
row.createCell(12).setCellValue(ObjectUtils.isEmpty(item.getPostcode()) ? "" : item.getPostcode());
}
// 合同信息
num = 1;
for (HouseholdPvExport item : list) {
// 获取当前插入数据行号
int lastRowNum = contactSheet.getLastRowNum() + 1;
Row row = contactSheet.createRow((short) (lastRowNum));
row.createCell(0).setCellValue(num);
num++;
row.createCell(1).setCellValue(ObjectUtils.isEmpty(item.getName()) ? "" : item.getName());
row.createCell(2).setCellValue(ObjectUtils.isEmpty(item.getIdNumber()) ? "" : item.getIdNumber());
row.createCell(3).setCellValue(ObjectUtils.isEmpty(item.getContactNumber()) ? "" : item.getContactNumber());
row.createCell(4).setCellValue(ObjectUtils.isEmpty(item.getPeriod()) ? "" : item.getPeriod());
row.createCell(5).setCellValue(ObjectUtils.isEmpty(item.getDescription()) ? "" : item.getDescription());
row.createCell(6).setCellValue(ObjectUtils.isEmpty(item.getGenerationNumber()) ? "" : item.getGenerationNumber());
}
// 设备信息
List<EquipMessageExport> equipMessage = iHouseholdPvService.selectExportEquipMessage(dto, dto.getIds());
for (EquipMessageExport item : equipMessage) {
// 获取当前插入数据行号
int lastRowNum = equipSheet.getLastRowNum() + 1;
Row row = equipSheet.createRow((short) (lastRowNum));
row.createCell(0).setCellValue(item.getNumSort());
row.createCell(1).setCellValue(ObjectUtils.isEmpty(item.getName()) ? "" : item.getName());
row.createCell(2).setCellValue(ObjectUtils.isEmpty(item.getIdNumber()) ? "" : item.getIdNumber());
row.createCell(3).setCellValue(ObjectUtils.isEmpty(item.getType()) ? "" : item.getType());
row.createCell(4).setCellValue(ObjectUtils.isEmpty(item.getEquipName()) ? "" : item.getEquipName());
row.createCell(5).setCellValue(ObjectUtils.isEmpty(item.getBrand()) ? "" : item.getBrand());
row.createCell(6).setCellValue(ObjectUtils.isEmpty(item.getSnCode()) ? "" : item.getSnCode());
row.createCell(7).setCellValue(ObjectUtils.isEmpty(item.getDescription()) ? "" : item.getDescription());
}
// 租赁物信息
num = 1;
for (HouseholdPvExport item : list) {
// 获取当前插入数据行号
int lastRowNum = leaseSheet.getLastRowNum() + 1;
Row row = leaseSheet.createRow((short) (lastRowNum));
row.createCell(0).setCellValue(num);
num++;
row.createCell(1).setCellValue(ObjectUtils.isEmpty(item.getName()) ? "" : item.getName());
row.createCell(2).setCellValue(ObjectUtils.isEmpty(item.getIdNumber()) ? "" : item.getIdNumber());
row.createCell(3).setCellValue(ObjectUtils.isEmpty(item.getInstallAddress()) ? "" : item.getInstallAddress());
row.createCell(4).setCellValue(ObjectUtils.isEmpty(item.getInstallDate()) ? "" : item.getInstallDate());
row.createCell(5).setCellValue(ObjectUtils.isEmpty(item.getEstimatedPower()) ? "" : item.getEstimatedPower());
row.createCell(6).setCellValue(ObjectUtils.isEmpty(item.getMonolithicPower()) ? "" : item.getMonolithicPower());
row.createCell(7).setCellValue(ObjectUtils.isEmpty(item.getInstallCount()) ? "" : item.getInstallCount());
row.createCell(8).setCellValue(ObjectUtils.isEmpty(item.getActualCapacity()) ? "" : item.getActualCapacity());
row.createCell(9).setCellValue(ObjectUtils.isEmpty(item.getStationType()) ? "" : item.getStationType());
row.createCell(10).setCellValue(ObjectUtils.isEmpty(item.getModuleType()) ? "" : item.getModuleType());
row.createCell(11).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()); workbook.write(response.getOutputStream());
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -522,4 +522,18 @@ public class HouseholdPvServiceImpl extends BaseService<HouseholdPvDto, Househol ...@@ -522,4 +522,18 @@ public class HouseholdPvServiceImpl extends BaseService<HouseholdPvDto, Househol
return householdPvDto; return householdPvDto;
} }
@Override
public List<EquipMessageExport> selectExportEquipMessage(HouseholdPvDto dto, List<Long> ids) {
String bizOrgCode = null;
if (!ObjectUtils.isEmpty(dto.getPlatformCompanyId())) {
bizOrgCode = getOrgCode(dto.getPlatformCompanyId());
if (!ObjectUtils.isEmpty(bizOrgCode)) {
dto.setBizOrgCode(bizOrgCode);
}
}
return householdPvMapper.selectExportEquipMessage(dto, ids);
}
} }
\ No newline at end of file
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