| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.enums.RealAssetsCategoryType; |
| | | import com.panzhihua.common.enums.RealAssetsFloorType; |
| | | import com.panzhihua.common.exceptions.ServiceException; |
| | | import com.panzhihua.common.model.dtos.community.ExportRealAssetsExcelDTO; |
| | | import com.panzhihua.common.model.dtos.community.PageComMngRealAssetsDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComMngRealAssetsExcelVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngRealAssetsVO; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.service_community.dao.ComMngRealAssetsDAO; |
| | | import com.panzhihua.service_community.dao.ComMngStructBuildTypeDAO; |
| | | import com.panzhihua.service_community.model.dos.ComMngRealAssetsDO; |
| | | import com.panzhihua.service_community.model.dos.ComMngStructBuildTypeDO; |
| | | import com.panzhihua.service_community.service.ComMngRealAssetsService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | * @date: 2021/3/19 11:55 |
| | | */ |
| | | @Service |
| | | public class ComMngRealAssetsServiceImpl extends ServiceImpl<ComMngRealAssetsDAO, ComMngRealAssetsDO> implements ComMngRealAssetsService { |
| | | public class ComMngRealAssetsServiceImpl extends ServiceImpl<ComMngRealAssetsDAO, ComMngRealAssetsDO> implements ComMngRealAssetsService { |
| | | |
| | | @Resource |
| | | private ComMngRealAssetsDAO comMngRealAssetsDAO; |
| | | @Resource |
| | | private ComMngStructBuildTypeDAO buildTypeDAO; |
| | | |
| | | @Override |
| | | public R pageQueryComMngRealAssets(PageComMngRealAssetsDTO pageComMngRealAssetsDTO) { |
| | |
| | | |
| | | @Override |
| | | public R saveComMngRealAssets(ComMngRealAssetsVO comMngRealAssetsVO) { |
| | | if(null!=comMngRealAssetsVO.getId() && comMngRealAssetsVO.getId()!=0){ |
| | | if (null != comMngRealAssetsVO.getId() && comMngRealAssetsVO.getId() != 0) { |
| | | //修改 |
| | | ComMngRealAssetsDO comMngRealAssetsDO = comMngRealAssetsDAO.selectById(comMngRealAssetsVO.getId()); |
| | | BeanUtils.copyProperties(comMngRealAssetsVO,comMngRealAssetsDO); |
| | | BeanUtils.copyProperties(comMngRealAssetsVO, comMngRealAssetsDO); |
| | | int update = comMngRealAssetsDAO.updateById(comMngRealAssetsDO); |
| | | if(update>0){ |
| | | if (update > 0) { |
| | | return R.ok(); |
| | | } |
| | | }else{ |
| | | } else { |
| | | ComMngRealAssetsDO comMngRealAssetsDO = new ComMngRealAssetsDO(); |
| | | BeanUtils.copyProperties(comMngRealAssetsVO,comMngRealAssetsDO); |
| | | BeanUtils.copyProperties(comMngRealAssetsVO, comMngRealAssetsDO); |
| | | int insert = comMngRealAssetsDAO.insert(comMngRealAssetsDO); |
| | | if(insert>0){ |
| | | if (insert > 0) { |
| | | return R.ok(); |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public R deleteComMngRealAssets(Long id) { |
| | | ComMngRealAssetsDO comMngRealAssetsDO = comMngRealAssetsDAO.selectById(id); |
| | | if(null==comMngRealAssetsDO){ |
| | | if (null == comMngRealAssetsDO) { |
| | | return R.fail("该资产不存在"); |
| | | } |
| | | int delete = comMngRealAssetsDAO.deleteById(id); |
| | | if(delete>0){ |
| | | if (delete > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail("删除失败"); |
| | |
| | | @Override |
| | | public R detailComMngRealAssets(Long id) { |
| | | ComMngRealAssetsDO comMngRealAssetsDO = comMngRealAssetsDAO.selectById(id); |
| | | if(null==comMngRealAssetsDO){ |
| | | if (null == comMngRealAssetsDO) { |
| | | return R.fail("该资产不存在"); |
| | | } |
| | | ComMngRealAssetsVO comMngRealAssetsVO = new ComMngRealAssetsVO(); |
| | | BeanUtils.copyProperties(comMngRealAssetsDO,comMngRealAssetsVO); |
| | | BeanUtils.copyProperties(comMngRealAssetsDO, comMngRealAssetsVO); |
| | | return R.ok(comMngRealAssetsVO); |
| | | } |
| | | |
| | | @Override |
| | | public R listSaveMngRealAssetsExcelVO(List<ComMngRealAssetsExcelVO> list, Long communityId) { |
| | | List<ComMngRealAssetsDO> comMngRealAssetsDOS = new ArrayList<>(); |
| | | list.forEach(l->{ |
| | | List<ComMngStructBuildTypeDO> buildTypeDOS = buildTypeDAO.selectList(new LambdaQueryWrapper<>()); |
| | | list.forEach(l -> { |
| | | ComMngStructBuildTypeDO buildTypeDO = buildTypeDOS.stream().filter(buildType -> buildType.getName().equals(l.getBuildTypeName())).findFirst().orElse(null); |
| | | if (buildTypeDO == null) { |
| | | throw new ServiceException("不存在类型建筑类型:" + l.getBuildTypeName()); |
| | | } |
| | | ComMngRealAssetsDO comMngRealAssetsDO = new ComMngRealAssetsDO(); |
| | | BeanUtils.copyProperties(l,comMngRealAssetsDO); |
| | | comMngRealAssetsDO.setBuildTypeId(buildTypeDO.getId()); |
| | | BeanUtils.copyProperties(l, comMngRealAssetsDO); |
| | | comMngRealAssetsDO.setCommunityId(communityId); |
| | | if (l.getFloorType().equals(RealAssetsFloorType.HIGN.getInfo())) { |
| | | comMngRealAssetsDO.setFloorType(RealAssetsFloorType.HIGN.getCode()); |
| | | } else if (l.getFloorType().equals(RealAssetsFloorType.CENTRE.getInfo())) { |
| | | comMngRealAssetsDO.setFloorType(RealAssetsFloorType.CENTRE.getCode()); |
| | | } else if (l.getFloorType().equals(RealAssetsFloorType.LOW.getInfo())) { |
| | | comMngRealAssetsDO.setFloorType(RealAssetsFloorType.LOW.getCode()); |
| | | } |
| | | if(l.getCategory().equals(RealAssetsCategoryType.PUBLIC.getInfo())){ |
| | | comMngRealAssetsDO.setCategory(RealAssetsCategoryType.PUBLIC.getCode()); |
| | | } |
| | | if(l.getCategory().equals(RealAssetsCategoryType.BUILD.getInfo())){ |
| | | comMngRealAssetsDO.setCategory(RealAssetsCategoryType.BUILD.getCode()); |
| | | } |
| | | comMngRealAssetsDOS.add(comMngRealAssetsDO); |
| | | }); |
| | | boolean batch = this.saveBatch(comMngRealAssetsDOS); |
| | | if(batch){ |
| | | if (batch) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail("请检查数据是否重复,格合是否正确"); |