fix (farm): 户主列表
-
This commit is contained in:
@@ -43,6 +43,6 @@ public class PlotInfoSaveReqVO {
|
||||
private Integer plotLeaseStatus;
|
||||
|
||||
@Schema(description = "租赁人信息")
|
||||
private PlotLesseeSaveReqVO plotLesseeSaveReqVO;
|
||||
private PlotLesseeSaveReqVO plotLessee;
|
||||
|
||||
}
|
||||
@@ -61,6 +61,6 @@ public class PlotLesseeInfoRespVO {
|
||||
private String plotLeaseStatusName;
|
||||
|
||||
@Schema(description = "租赁人信息")
|
||||
private PlotLesseeDetailsRespVO plotLesseeDetailsRespVO;
|
||||
private PlotLesseeDetailsRespVO plotLessee;
|
||||
|
||||
}
|
||||
@@ -26,6 +26,8 @@ import org.springframework.validation.annotation.Validated;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
||||
@@ -71,18 +73,24 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
||||
|
||||
PlotLesseeSaveReqVO plotLesseeSaveReqVO = createReqVO.getPlotLesseeSaveReqVO();
|
||||
PlotLesseeDO plotLesseeDO = BeanUtils.toBean(plotLesseeSaveReqVO, PlotLesseeDO.class);
|
||||
plotLesseeDO.setId(IdUtil.fastUUID());
|
||||
plotLesseeDO.setTenantId(String.valueOf(user.getTenantId()));
|
||||
plotLesseeDO.setLeaseStatus(CommonConstants.YES_CODE);
|
||||
plotLesseeDO.setBaseId(createReqVO.getBaseId());
|
||||
plotLesseeDO.setPlotId(plotInfo.getId());
|
||||
plotLesseeDO.setPlotName(plotInfo.getPlotName());
|
||||
plotLesseeMapper.insert(plotLesseeDO);
|
||||
insertLessee(plotLesseeDO, createReqVO.getBaseId(), plotInfo.getId(), plotInfo.getPlotName());
|
||||
|
||||
// 返回
|
||||
return plotInfo.getId();
|
||||
}
|
||||
|
||||
private void insertLessee(PlotLesseeDO plotLesseeDO,String baseId,String plotId,String plotName) {
|
||||
LoginUser user = getLoginUser();
|
||||
|
||||
plotLesseeDO.setId(IdUtil.fastUUID());
|
||||
plotLesseeDO.setTenantId(String.valueOf(user.getTenantId()));
|
||||
plotLesseeDO.setLeaseStatus(CommonConstants.YES_CODE);
|
||||
plotLesseeDO.setBaseId(baseId);
|
||||
plotLesseeDO.setPlotId(plotId);
|
||||
plotLesseeDO.setPlotName(plotName);
|
||||
plotLesseeMapper.insert(plotLesseeDO);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void updatePlotInfo(PlotInfoSaveReqVO updateReqVO) {
|
||||
@@ -91,19 +99,26 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
||||
// 校验地块面积
|
||||
validatePlotArea(updateReqVO.getBaseId(), updateReqVO.getId(), updateReqVO.getPlotArea());
|
||||
// 更新
|
||||
PlotInfoDO updateObj = BeanUtils.toBean(updateReqVO, PlotInfoDO.class);
|
||||
plotInfoMapper.updateById(updateObj);
|
||||
PlotInfoDO plotInfo = BeanUtils.toBean(updateReqVO, PlotInfoDO.class);
|
||||
plotInfoMapper.updateById(plotInfo);
|
||||
|
||||
// 重置所有租赁状态为: 未租
|
||||
List<PlotLesseeDO> doList = plotLesseeMapper.selectList("plot_id", updateReqVO.getId());
|
||||
doList.forEach(e -> e.setLeaseStatus(CommonConstants.NO_CODE));
|
||||
plotLesseeMapper.updateBatch(doList);
|
||||
Set<String> collect = doList.stream().map(e-> e.getLeaseIdCard()).collect(Collectors.toSet());
|
||||
|
||||
// 指定当前的租户状态为: 已租
|
||||
PlotLesseeSaveReqVO plotLesseeSaveReqVO = updateReqVO.getPlotLesseeSaveReqVO();
|
||||
String idCard = plotLesseeSaveReqVO.getLeaseIdCard();
|
||||
PlotLesseeDO plotLesseeDO = BeanUtils.toBean(plotLesseeSaveReqVO, PlotLesseeDO.class);
|
||||
if (collect.contains(idCard)) {
|
||||
plotLesseeDO.setLeaseStatus(CommonConstants.YES_CODE);
|
||||
plotLesseeMapper.updateById(plotLesseeDO);
|
||||
} else {
|
||||
insertLessee(plotLesseeDO, updateReqVO.getBaseId(), plotInfo.getId(), plotInfo.getPlotName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user