|
|
@ -3,20 +3,28 @@ package com.epmet.plugin.power.modules.rent.service.impl; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.plugin.power.modules.rent.dao.RentContractInfoDao; |
|
|
|
import com.epmet.plugin.power.dto.rent.RentContractFileDTO; |
|
|
|
import com.epmet.plugin.power.dto.rent.RentContractInfoDTO; |
|
|
|
import com.epmet.plugin.power.dto.rent.RentTenantInfoDTO; |
|
|
|
import com.epmet.plugin.power.modules.rent.dao.RentContractInfoDao; |
|
|
|
import com.epmet.plugin.power.modules.rent.entity.RentContractFileEntity; |
|
|
|
import com.epmet.plugin.power.modules.rent.entity.RentContractInfoEntity; |
|
|
|
import com.epmet.plugin.power.modules.rent.entity.RentTenantInfoEntity; |
|
|
|
import com.epmet.plugin.power.modules.rent.redis.RentContractInfoRedis; |
|
|
|
import com.epmet.plugin.power.modules.rent.service.RentContractFileService; |
|
|
|
import com.epmet.plugin.power.modules.rent.service.RentContractInfoService; |
|
|
|
import com.epmet.plugin.power.modules.rent.service.RentTenantInfoService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
@ -32,6 +40,12 @@ public class RentContractInfoServiceImpl extends BaseServiceImpl<RentContractInf |
|
|
|
@Autowired |
|
|
|
private RentContractInfoRedis rentContractInfoRedis; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RentTenantInfoService rentTenantInfoService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RentContractFileService rentContractFileService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<RentContractInfoDTO> page(Map<String, Object> params) { |
|
|
|
IPage<RentContractInfoEntity> page = baseDao.selectPage( |
|
|
@ -48,11 +62,48 @@ public class RentContractInfoServiceImpl extends BaseServiceImpl<RentContractInf |
|
|
|
return ConvertUtils.sourceToTarget(entityList, RentContractInfoDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<RentContractInfoEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
private QueryWrapper<RentContractInfoEntity> getWrapper(Map<String, Object> params) { |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
String gridId = (String) params.get("gridId"); |
|
|
|
String villageId = (String) params.get("villageId"); |
|
|
|
String buildId = (String) params.get("buildId"); |
|
|
|
String unitId = (String) params.get("unitId"); |
|
|
|
String homeId = (String) params.get("homeId"); |
|
|
|
String state = (String) params.get("state"); |
|
|
|
String lessorName = (String) params.get("lessorName"); |
|
|
|
String lessorIdCard = (String) params.get("lessorIdCard"); |
|
|
|
String lessorMobile = (String) params.get("lessorMobile"); |
|
|
|
String lesseeName = (String) params.get("lesseeName"); |
|
|
|
String lesseeIdCard = (String) params.get("lesseeIdCard"); |
|
|
|
String lesseeMobile = (String) params.get("lesseeMobile"); |
|
|
|
String startTime = (String) params.get("startTime"); |
|
|
|
String endTime = (String) params.get("endTime"); |
|
|
|
String reviewStartTime = (String) params.get("reviewStartTime"); |
|
|
|
String reviewEndTime = (String) params.get("reviewEndTime"); |
|
|
|
String signStartTime = (String) params.get("signStartTime"); |
|
|
|
String signEndTime = (String) params.get("signEndTime"); |
|
|
|
String endDate = (String) params.get("endDate"); |
|
|
|
|
|
|
|
QueryWrapper<RentContractInfoEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(gridId), "GRID_ID", gridId); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(villageId), "VILLAGE_ID", villageId); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(buildId), "BUILD_ID", buildId); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(unitId), "UNIT_ID", unitId); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(homeId), "HOME_ID", homeId); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(state), "STATE", state); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(lessorName), "LESSOR_NAME", lessorName); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(lessorIdCard), "LESSOR_ID_CARD", lessorIdCard); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(lessorMobile), "LESSOR_MOBILE", lessorMobile); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(lesseeName), "LESSEE_NAME", lesseeName); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(lesseeIdCard), "LESSEE_ID_CARD", lesseeIdCard); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(lesseeMobile), "LESSEE_MOBILE", lesseeMobile); |
|
|
|
wrapper.ge(StringUtils.isNotBlank(reviewStartTime), "REVIEW_DATE", reviewStartTime); |
|
|
|
wrapper.le(StringUtils.isNotBlank(reviewEndTime), "REVIEW_DATE", reviewEndTime); |
|
|
|
wrapper.ge(StringUtils.isNotBlank(signStartTime), "SIGN_DATE", signStartTime); |
|
|
|
wrapper.le(StringUtils.isNotBlank(signEndTime), "SIGN_DATE", signEndTime); |
|
|
|
|
|
|
|
wrapper.eq(StringUtils.isNotBlank(endDate), "END_DATE", endDate); |
|
|
|
|
|
|
|
return wrapper; |
|
|
|
} |
|
|
@ -60,7 +111,29 @@ public class RentContractInfoServiceImpl extends BaseServiceImpl<RentContractInf |
|
|
|
@Override |
|
|
|
public RentContractInfoDTO get(String id) { |
|
|
|
RentContractInfoEntity entity = baseDao.selectById(id); |
|
|
|
return ConvertUtils.sourceToTarget(entity, RentContractInfoDTO.class); |
|
|
|
RentContractInfoDTO dto = ConvertUtils.sourceToTarget(entity, RentContractInfoDTO.class); |
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>(4); |
|
|
|
params.put("contractId", id); |
|
|
|
|
|
|
|
// 取出租客信息
|
|
|
|
List<RentTenantInfoDTO> tenantList = rentTenantInfoService.list(params); |
|
|
|
tenantList.forEach(item -> { |
|
|
|
// 租客信息补充照片信息
|
|
|
|
params.put("referenceId", item.getId()); |
|
|
|
params.put("fileType", NumConstant.ZERO_STR); |
|
|
|
List<RentContractFileDTO> imgList = rentContractFileService.list(params); |
|
|
|
item.setImgList(imgList); |
|
|
|
}); |
|
|
|
dto.setTenantList(tenantList); |
|
|
|
|
|
|
|
params.put("referenceId", dto.getId()); |
|
|
|
params.put("fileType", NumConstant.ONE_STR); |
|
|
|
// 取出合同文件信息
|
|
|
|
List<RentContractFileDTO> fileList = rentContractFileService.list(params); |
|
|
|
dto.setFileList(fileList); |
|
|
|
|
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -68,6 +141,7 @@ public class RentContractInfoServiceImpl extends BaseServiceImpl<RentContractInf |
|
|
|
public void save(RentContractInfoDTO dto) { |
|
|
|
RentContractInfoEntity entity = ConvertUtils.sourceToTarget(dto, RentContractInfoEntity.class); |
|
|
|
insert(entity); |
|
|
|
updateTenantAndFile(entity.getId(), dto); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -75,6 +149,7 @@ public class RentContractInfoServiceImpl extends BaseServiceImpl<RentContractInf |
|
|
|
public void update(RentContractInfoDTO dto) { |
|
|
|
RentContractInfoEntity entity = ConvertUtils.sourceToTarget(dto, RentContractInfoEntity.class); |
|
|
|
updateById(entity); |
|
|
|
updateTenantAndFile(entity.getId(), dto); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -84,4 +159,48 @@ public class RentContractInfoServiceImpl extends BaseServiceImpl<RentContractInf |
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
private void updateTenantAndFile(String contractId, RentContractInfoDTO dto) { |
|
|
|
Map<String, Object> params = new HashMap<>(8); |
|
|
|
params.put("contractId", contractId); |
|
|
|
params.put("referenceId", contractId); |
|
|
|
// 删除租客和合同文件
|
|
|
|
rentTenantInfoService.deletePhysical(params); |
|
|
|
rentContractFileService.deletePhysical(params); |
|
|
|
|
|
|
|
if (!dto.getTenantList().isEmpty()) { |
|
|
|
List<RentTenantInfoEntity> tenantList = ConvertUtils.sourceToTarget(dto.getTenantList(), RentTenantInfoEntity.class); |
|
|
|
tenantList.forEach(tenant -> { |
|
|
|
if (StringUtils.isNotBlank(tenant.getId())) { |
|
|
|
// 如果是修改,先删除之前的头像
|
|
|
|
params.put("referenceId", tenant.getId()); |
|
|
|
params.put("fileType", NumConstant.ZERO_STR); |
|
|
|
rentContractFileService.deletePhysical(params); |
|
|
|
} |
|
|
|
tenant.setContractId(contractId); |
|
|
|
tenant.setType(NumConstant.ONE_STR); |
|
|
|
}); |
|
|
|
rentTenantInfoService.insertBatch(tenantList); |
|
|
|
// 处理租客头像
|
|
|
|
dto.getTenantList().forEach(tenant -> { |
|
|
|
if (!tenant.getImgList().isEmpty()) { |
|
|
|
List<RentContractFileEntity> imgList = ConvertUtils.sourceToTarget(tenant.getImgList(), RentContractFileEntity.class); |
|
|
|
imgList.forEach(img -> { |
|
|
|
img.setReferenceId(tenant.getId()); |
|
|
|
img.setFileType(NumConstant.ZERO_STR); |
|
|
|
}); |
|
|
|
rentContractFileService.insertBatch(imgList); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
if (!dto.getFileList().isEmpty()) { |
|
|
|
List<RentContractFileEntity> fileList = ConvertUtils.sourceToTarget(dto.getFileList(), RentContractFileEntity.class); |
|
|
|
fileList.forEach(item -> { |
|
|
|
item.setReferenceId(contractId); |
|
|
|
item.setFileType(NumConstant.ONE_STR); |
|
|
|
}); |
|
|
|
rentContractFileService.insertBatch(fileList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |