Commit 707bd684 authored by lisong's avatar lisong

更新

parent 10d2306c
......@@ -106,4 +106,8 @@ public class HouseholdPvDto extends BaseDto {
private List<Long> ids;
/**
* 安装地址
*/
private String installAddress;
}
......@@ -13,6 +13,7 @@ public class HouseholdPvExport {
* 基础信息
*/
private String platformCompanyId;
private String districtId;
private String number;
private String name;
private String sex;
......
......@@ -10,7 +10,7 @@ public class HouseholdPvImport {
@ExcelProperty(value = "所属场站", index = 0)
private String platformCompanyId;
@ColumnWidth(15)
@ExcelProperty(value = "所属区域", index = 1)
@ExcelProperty(value = "乡镇", index = 1)
private String districtId;
@ColumnWidth(15)
@ExcelProperty(value = "户号", index = 2)
......
......@@ -17,6 +17,8 @@ public interface HouseholdPvDistrictMapper extends BaseMapper<HouseholdPvDistric
List<CompanyTreeDto> getList();
List<CompanyTreeDto> getListByParentId(@Param("bizOrgCode") String bizOrgCode ,@Param("parentId") Long parentId);
Integer countTreeNodesById(@Param("id") Long id);
Integer countHouseholdById(@Param("id") Long id);
......
......@@ -17,7 +17,7 @@ public interface IHouseholdPvDistrictService extends IService<HouseholdPvDistric
List<CompanyTreeDto> getTree();
List<CompanyTreeDto> getBusinessTree();
List<CompanyTreeDto> getBusinessTree(Long parentId);
HouseholdPvDistrict treeAdd(Long parentId, String name);
......
......@@ -31,4 +31,6 @@ public interface IHouseholdPvService extends IService<HouseholdPv>{
HouseholdPvDto update(HouseholdPvDto householdPvDto);
HouseholdPvDto getBySeq(Long id);
Integer countRepeat(HouseholdPvDto householdPvDto, String type);
}
......@@ -27,4 +27,16 @@
<select id="selectIds" resultType="java.lang.Long">
select hp.sequence_nbr from household_pv_district hp where hp.biz_org_code like concat(#{bizOrgCode}, '%')
</select>
<select id="getListByParentId" resultType="com.yeejoin.amos.boot.module.jxiop.api.dto.CompanyTreeDto">
SELECT
hpd.sequence_nbr AS id,
hpd.NAME,
hpd.parent_id AS parentId,
hpd.parent_type AS type
FROM
household_pv_district hpd
WHERE
hpd.is_delete = 0 and hpd.sequence_nbr != #{parentId}
AND hpd.biz_org_code LIKE CONCAT(#{bizOrgCode}, '%' )
</select>
</mapper>
......@@ -17,6 +17,7 @@
hp.address,
hp.postcode,
hp.service_address AS serviceAddress,
hp.district_id AS districtId,
hpc.number AS contactNumber,
hpc.period,
hpc.description ,
......@@ -61,13 +62,14 @@
SELECT * from household_pv_device hpd WHERE hpd.household_pv_id = #{id}
</select>
<select id="selectPageMessage" resultType="com.yeejoin.amos.boot.module.jxiop.api.dto.HouseholdPvDto">
select * from household_pv hp
select hp.*,hpl.install_address as installAddress from household_pv hp
LEFT JOIN household_pv_lease hpl on hp.sequence_nbr = hpl.household_pv_id
<where>
<if test="dto.name != null and dto.name != ''">
and hp.name like concat('%',#{dto.name},'%')
</if>
<if test="dto.residenceAddress != null and dto.residenceAddress != ''">
and hp.residence_address like concat('%',#{dto.residenceAddress},'%')
<if test="dto.installAddress != null and dto.installAddress != ''">
and hpl.install_address like concat('%',#{dto.installAddress},'%')
</if>
<if test="dto.number != null and dto.number != ''">
and hp.number like concat('%',#{dto.number},'%')
......@@ -76,6 +78,7 @@
and hp.biz_org_code like concat('%',#{dto.bizOrgCode},'%')
</if>
</where>
order by hp.rec_date desc
</select>
</mapper>
......@@ -61,6 +61,13 @@ public class HouseholdPvController extends BaseController {
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增户用光伏表", notes = "新增户用光伏表")
public ResponseModel<HouseholdPvDto> save(@RequestBody HouseholdPvDto model) {
Integer count = householdPvServiceImpl.countRepeat(model, "add");
if (count > 0){
ResponseModel<HouseholdPvDto> result = new ResponseModel<>();
result.setStatus(500);
result.setMessage("户号已经存在");
return result;
}
model = householdPvServiceImpl.save(model);
return ResponseHelper.buildResponse(model);
}
......@@ -76,6 +83,13 @@ public class HouseholdPvController extends BaseController {
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新户用光伏表", notes = "根据sequenceNbr更新户用光伏表")
public ResponseModel<HouseholdPvDto> updateBySequenceNbrHouseholdPv(@RequestBody HouseholdPvDto model, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr);
Integer count = householdPvServiceImpl.countRepeat(model, "upd");
if (count > 0){
ResponseModel<HouseholdPvDto> result = new ResponseModel<>();
result.setStatus(500);
result.setMessage("户号已经存在");
return result;
}
return ResponseHelper.buildResponse(householdPvServiceImpl.update(model));
}
......@@ -175,31 +189,32 @@ public class HouseholdPvController extends BaseController {
int lastRowNum = sheet.getLastRowNum() + 1;
Row row = sheet.createRow((short) (lastRowNum));
row.createCell(0).setCellValue(ObjectUtils.isEmpty(item.getPlatformCompanyId()) ? "" : item.getPlatformCompanyId());
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.getSex()) ? "" : item.getSex());
row.createCell(4).setCellValue(ObjectUtils.isEmpty(item.getIdNumber()) ? "" : item.getIdNumber());
row.createCell(5).setCellValue(ObjectUtils.isEmpty(item.getExpiryTime()) ? "" : item.getExpiryTime());
row.createCell(6).setCellValue(ObjectUtils.isEmpty(item.getIssuingAuthority()) ? "" : item.getIssuingAuthority());
row.createCell(7).setCellValue(ObjectUtils.isEmpty(item.getResidenceAddress()) ? "" : item.getResidenceAddress());
row.createCell(8).setCellValue(ObjectUtils.isEmpty(item.getPhone()) ? "" : item.getPhone());
row.createCell(9).setCellValue(ObjectUtils.isEmpty(item.getAddress()) ? "" : item.getAddress());
row.createCell(10).setCellValue(ObjectUtils.isEmpty(item.getPostcode()) ? "" : item.getPostcode());
row.createCell(11).setCellValue(ObjectUtils.isEmpty(item.getServiceAddress()) ? "" : item.getServiceAddress());
row.createCell(12).setCellValue(ObjectUtils.isEmpty(item.getContactNumber()) ? "" : item.getContactNumber());
row.createCell(13).setCellValue(ObjectUtils.isEmpty(item.getPeriod()) ? "" : item.getPeriod());
row.createCell(14).setCellValue(ObjectUtils.isEmpty(item.getDescription()) ? "" : item.getDescription());
row.createCell(15).setCellValue(ObjectUtils.isEmpty(item.getEquipmentMessage()) ? "" : item.getEquipmentMessage());
row.createCell(16).setCellValue(ObjectUtils.isEmpty(item.getInstallAddress()) ? "" : item.getInstallAddress());
row.createCell(17).setCellValue(ObjectUtils.isEmpty(item.getInstallDate()) ? "" : item.getInstallDate());
row.createCell(18).setCellValue(ObjectUtils.isEmpty(item.getEstimatedPower()) ? "" : item.getEstimatedPower());
row.createCell(19).setCellValue(ObjectUtils.isEmpty(item.getMonolithicPower()) ? "" : item.getMonolithicPower());
row.createCell(20).setCellValue(ObjectUtils.isEmpty(item.getInstallCount()) ? "" : item.getInstallCount());
row.createCell(21).setCellValue(ObjectUtils.isEmpty(item.getActualCapacity()) ? "" : item.getActualCapacity());
row.createCell(22).setCellValue(ObjectUtils.isEmpty(item.getStationType()) ? "" : item.getStationType());
row.createCell(23).setCellValue(ObjectUtils.isEmpty(item.getModuleType()) ? "" : item.getModuleType());
row.createCell(24).setCellValue(ObjectUtils.isEmpty(item.getInstallStation()) ? "" : item.getInstallStation());
row.createCell(25).setCellValue(ObjectUtils.isEmpty(item.getInstallDescription()) ? "" : item.getInstallDescription());
row.createCell(1).setCellValue(ObjectUtils.isEmpty(item.getDistrictId()) ? "" : item.getDistrictId());
row.createCell(2).setCellValue(ObjectUtils.isEmpty(item.getNumber()) ? "" : item.getNumber());
row.createCell(3).setCellValue(ObjectUtils.isEmpty(item.getName()) ? "" : item.getName());
row.createCell(4).setCellValue(ObjectUtils.isEmpty(item.getSex()) ? "" : item.getSex());
row.createCell(5).setCellValue(ObjectUtils.isEmpty(item.getIdNumber()) ? "" : item.getIdNumber());
row.createCell(6).setCellValue(ObjectUtils.isEmpty(item.getExpiryTime()) ? "" : item.getExpiryTime());
row.createCell(7).setCellValue(ObjectUtils.isEmpty(item.getIssuingAuthority()) ? "" : item.getIssuingAuthority());
row.createCell(8).setCellValue(ObjectUtils.isEmpty(item.getResidenceAddress()) ? "" : item.getResidenceAddress());
row.createCell(9).setCellValue(ObjectUtils.isEmpty(item.getPhone()) ? "" : item.getPhone());
row.createCell(10).setCellValue(ObjectUtils.isEmpty(item.getAddress()) ? "" : item.getAddress());
row.createCell(11).setCellValue(ObjectUtils.isEmpty(item.getPostcode()) ? "" : item.getPostcode());
row.createCell(12).setCellValue(ObjectUtils.isEmpty(item.getServiceAddress()) ? "" : item.getServiceAddress());
row.createCell(13).setCellValue(ObjectUtils.isEmpty(item.getContactNumber()) ? "" : item.getContactNumber());
row.createCell(14).setCellValue(ObjectUtils.isEmpty(item.getPeriod()) ? "" : item.getPeriod());
row.createCell(15).setCellValue(ObjectUtils.isEmpty(item.getDescription()) ? "" : item.getDescription());
row.createCell(16).setCellValue(ObjectUtils.isEmpty(item.getEquipmentMessage()) ? "" : item.getEquipmentMessage());
row.createCell(17).setCellValue(ObjectUtils.isEmpty(item.getInstallAddress()) ? "" : item.getInstallAddress());
row.createCell(18).setCellValue(ObjectUtils.isEmpty(item.getInstallDate()) ? "" : item.getInstallDate());
row.createCell(19).setCellValue(ObjectUtils.isEmpty(item.getEstimatedPower()) ? "" : item.getEstimatedPower());
row.createCell(20).setCellValue(ObjectUtils.isEmpty(item.getMonolithicPower()) ? "" : item.getMonolithicPower());
row.createCell(21).setCellValue(ObjectUtils.isEmpty(item.getInstallCount()) ? "" : item.getInstallCount());
row.createCell(22).setCellValue(ObjectUtils.isEmpty(item.getActualCapacity()) ? "" : item.getActualCapacity());
row.createCell(23).setCellValue(ObjectUtils.isEmpty(item.getStationType()) ? "" : item.getStationType());
row.createCell(24).setCellValue(ObjectUtils.isEmpty(item.getModuleType()) ? "" : item.getModuleType());
row.createCell(25).setCellValue(ObjectUtils.isEmpty(item.getInstallStation()) ? "" : item.getInstallStation());
row.createCell(26).setCellValue(ObjectUtils.isEmpty(item.getInstallDescription()) ? "" : item.getInstallDescription());
});
response.setCharacterEncoding("UTF-8");
......
......@@ -131,8 +131,8 @@ public class HouseholdPvDistrictController extends BaseController {
@GetMapping(value = "/getBusinessTree")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "厂站树", notes = "厂站树")
public ResponseModel<Object> getBusinessTree() {
return ResponseHelper.buildResponse(householdPvDistrictService.getBusinessTree());
public ResponseModel<Object> getBusinessTree(@RequestParam("platformCompanyId") Long parentId) {
return ResponseHelper.buildResponse(householdPvDistrictService.getBusinessTree(parentId));
}
/**
......
......@@ -25,6 +25,7 @@ import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
......@@ -133,11 +134,30 @@ public class HouseholdPvDistrictServiceImpl extends BaseService<HouseholdPvDistr
}
@Override
public List<CompanyTreeDto> getBusinessTree() {
List<CompanyTreeDto> list = householdPvDistrictMapper.getList();
public List<CompanyTreeDto> getBusinessTree(Long parentId) {
String orgCode = getOrgCode(parentId);
if (ObjectUtils.isEmpty(orgCode)){
return new ArrayList<>();
}
List<CompanyTreeDto> list = householdPvDistrictMapper.getListByParentId(orgCode, parentId);
return list.stream().filter(a -> list.stream().noneMatch(c -> c.getId().equals(a.getParentId()))).peek(b -> b.setChildren(getCompanyBuildingChildrenTree(b.getId(), list))).collect(Collectors.toList());
}
private String getOrgCode(Long platformCompanyId) {
String bizOrgCode = null;
HouseholdPvDistrict parentDetail = householdPvDistrictMapper.selectById(platformCompanyId);
if (ObjectUtils.isEmpty(parentDetail)) {
FeignClientResult<CompanyModel> companyModelFeignClientResult = Privilege.companyClient.seleteOne(platformCompanyId);
CompanyModel result = companyModelFeignClientResult.getResult();
if (!ObjectUtils.isEmpty(result) && !ObjectUtils.isEmpty(result.getLevel()) && "station".equals(result.getLevel())) {
bizOrgCode = result.getOrgCode();
}
} else {
bizOrgCode = parentDetail.getBizOrgCode();
}
return bizOrgCode;
}
private void change(Collection<UserOrgTreeModel> data, List<CompanyTreeDto> result) {
data.forEach(item -> {
CompanyTreeDto dto = new CompanyTreeDto();
......
......@@ -141,7 +141,7 @@ public class HouseholdPvServiceImpl extends BaseService<HouseholdPvDto, Househol
householdPv.setBizOrgCode(getOrgCode(householdPv.getPlatformCompanyId()));
}
}
// 所属区域
// 所属乡镇
if (!ObjectUtils.isEmpty(item.getDistrictId())) {
if (map.containsKey(item.getDistrictId())) {
householdPv.setDistrictId(Long.parseLong(String.valueOf(map.get(item.getDistrictId()))));
......@@ -182,6 +182,7 @@ public class HouseholdPvServiceImpl extends BaseService<HouseholdPvDto, Househol
Map<String, Object> companyMap = companyList();
List<HouseholdPvExport> householdPvExports = householdPvMapper.selectExportList(dto, ids);
householdPvExports.forEach(item -> {
// 所属场站
if (!ObjectUtils.isEmpty(item.getPlatformCompanyId())) {
if (companyMap.containsKey(item.getPlatformCompanyId())) {
item.setPlatformCompanyId(companyMap.get(item.getPlatformCompanyId()).toString());
......@@ -189,6 +190,22 @@ public class HouseholdPvServiceImpl extends BaseService<HouseholdPvDto, Househol
item.setPlatformCompanyId("");
}
}
// 乡镇
if (!ObjectUtils.isEmpty(item.getDistrictId())) {
if (companyMap.containsKey(item.getDistrictId())) {
item.setDistrictId(companyMap.get(item.getDistrictId()).toString());
} else {
item.setDistrictId("");
}
}
// 安装信息-所属场站
if (!ObjectUtils.isEmpty(item.getInstallStation())) {
if (companyMap.containsKey(item.getInstallStation())) {
item.setInstallStation(companyMap.get(item.getInstallStation()).toString());
} else {
item.setInstallStation("");
}
}
if (!ObjectUtils.isEmpty(item.getPeriod())) {
JSONArray objects = JSON.parseArray(item.getPeriod());
if (!ObjectUtils.isEmpty(objects) && objects.size() >= 2) {
......@@ -299,6 +316,16 @@ public class HouseholdPvServiceImpl extends BaseService<HouseholdPvDto, Househol
}
@Override
public Integer countRepeat(HouseholdPvDto householdPvDto, String type) {
LambdaQueryWrapper<HouseholdPv> lambda = new QueryWrapper<HouseholdPv>().lambda();
lambda.eq(HouseholdPv::getNumber, householdPvDto.getNumber());
if ("upd".equals(type)){
lambda.ne(HouseholdPv::getSequenceNbr, householdPvDto.getSequenceNbr());
}
return householdPvMapper.selectCount(lambda);
}
@Override
public HouseholdPvDto getBySeq(Long id) {
HouseholdPv householdPv = this.getById(id);
HouseholdPvDto householdPvDto = new HouseholdPvDto();
......
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