Null
2021-03-19 fa5a0d6eca31dfe7dde16a403c192df4494273eb
实有资产管理
9个文件已添加
5个文件已修改
762 ■■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngRealAssetsExcelListen.java 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/ExportRealAssetsExcelDTO.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/PageComMngCarDTO.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/PageComMngRealAssetsDTO.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngRealAssetsExcelVO.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngRealAssetsVO.java 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/CommonDataApi.java 111 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommonDataApi.java 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngCarDAO.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngRealAssetsDAO.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ComMngRealAssetsDO.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngRealAssetsService.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngRealAssetsServiceImpl.java 116 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngRealAssetsExcelListen.java
New file
@@ -0,0 +1,60 @@
package com.panzhihua.common.listen;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.fastjson.JSONObject;
import com.panzhihua.common.exceptions.ServiceException;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComMngRealAssetsExcelVO;
import com.panzhihua.common.model.vos.community.ComMngRealCompanyExcelVO;
import com.panzhihua.common.service.community.CommunityService;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
import java.util.List;
/**
 * @description: 实有单位导入监听
 * @author: Null
 * @date: 2021/3/11 13:26
 */
@Slf4j
public class ComMngRealAssetsExcelListen extends AnalysisEventListener<ComMngRealAssetsExcelVO> {
    private CommunityService communityService;
    private Long communityId;
    public ComMngRealAssetsExcelListen(CommunityService communityService, Long communityId){
        this.communityService = communityService;
        this.communityId = communityId;
    }
    private static final int BATCH_COUNT = 100;
    private List<ComMngRealAssetsExcelVO> list = new ArrayList<>();
    @Override
    public void invoke(ComMngRealAssetsExcelVO comMngRealCompanyExcelVO, AnalysisContext analysisContext) {
        list.add(comMngRealCompanyExcelVO);
        // 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
        if(list.size() >= BATCH_COUNT){
            log.info("excel导入数据【{}】", JSONObject.toJSONString(list));
            R r = this.communityService.listSaveMngRealAssetsExcelVO(list,this.communityId);
            if (!R.isOk(r)) {
                throw new ServiceException(r.getMsg());
            }
            list.clear();           //清空list
        }
    }
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        log.info("excel导入数据【{}】", JSONObject.toJSONString(list));
        R r = this.communityService.listSaveMngRealAssetsExcelVO(list,this.communityId);//确保最后遗留的数据保存在数据库中
        if (!R.isOk(r)) {
            throw new ServiceException(r.getMsg());
        }
    }
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/ExportRealAssetsExcelDTO.java
New file
@@ -0,0 +1,22 @@
package com.panzhihua.common.model.dtos.community;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
 * @description: 实有资产导出请求参数
 * @author: Null
 * @date: 2021/3/11 10:36
 */
@Data
@ApiModel("实有资产导出请求参数")
public class ExportRealAssetsExcelDTO {
    @ApiModelProperty(value = "社区id",hidden = true)
    private Long communityId;
    @ApiModelProperty(value = "资产名称")
    private String name;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/PageComMngCarDTO.java
@@ -16,8 +16,8 @@
    @ApiModelProperty(value = "社区id")
    private Long communityId;
    @ApiModelProperty(value = "小区id")
    private Long areaId;
    @ApiModelProperty(value = "小区名称")
    private String areaName;
    @ApiModelProperty("车主姓名")
    private String name;
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/PageComMngRealAssetsDTO.java
New file
@@ -0,0 +1,29 @@
package com.panzhihua.common.model.dtos.community;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
 * @description: 实有资产列表请求参数
 * @author: Null
 * @date: 2021/3/11 10:36
 */
@Data
@ApiModel("实有资产列表请求参数")
public class PageComMngRealAssetsDTO {
    @ApiModelProperty(value = "社区id",hidden = true)
    private Long communityId;
    @ApiModelProperty(value = "资产名称")
    private String name;
    @ApiModelProperty(value = "分页-当前页数",example = "1")
    private Long pageNum;
    @ApiModelProperty(value = "分页-每页记录数",example = "10")
    private Long pageSize;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngRealAssetsExcelVO.java
New file
@@ -0,0 +1,38 @@
package com.panzhihua.common.model.vos.community;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.io.Serializable;
/**
 * @description: 实有单位
 * @author: Null
 * @date: 2021/3/19 12:02
 */
@Data
public class ComMngRealAssetsExcelVO implements Serializable {
    @ExcelProperty(value = "资产名称" ,index = 0)
    private String name;
    @ExcelProperty(value = "位置" ,index = 1)
    private String address;
    @ExcelProperty(value = "分类" ,index = 2)
    private String category;
    @ExcelProperty(value = "占地面积" ,index = 3)
    private String square;
    @ExcelProperty(value = "数量" ,index = 4)
    private Integer num;
    @ExcelProperty(value = "建筑类型" ,index = 5)
    private String buildTypeName;
    @ExcelProperty(value = "楼层类型" ,index = 6)
    private String floorType;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngRealAssetsVO.java
New file
@@ -0,0 +1,64 @@
package com.panzhihua.common.model.vos.community;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
 * @description: 实有单位
 * @author: Null
 * @date: 2021/3/19 12:02
 */
@Data
public class ComMngRealAssetsVO implements Serializable {
    @ApiModelProperty("主键")
    private Long id;
    @ApiModelProperty(value = "社区ID",hidden = true)
    private Long communityId;
    @ApiModelProperty("资产名称")
    private String name;
    @ApiModelProperty("分类:1-建筑类 2-公共设施类")
    private Integer category;
    @ApiModelProperty("建筑类型ID")
    private Long buildTypeId;
    @ApiModelProperty("建筑类型名称")
    private String buildTypeName;
    @ApiModelProperty("楼层类型:1-高层 2-中层 3-底层")
    private Integer floorType;
    @ApiModelProperty("数量")
    private Integer num;
    @ApiModelProperty("面积")
    private BigDecimal square;
    @ApiModelProperty("省份行政区划代码")
    private Integer provinceAdcode;
    @ApiModelProperty("城市行政区划代码")
    private Integer cityAdcode;
    /**区县行政区划代码*/
    @ApiModelProperty("区县行政区划代码")
    private Integer districtAdcode;
    @ApiModelProperty("详细地址")
    private String address;
    /**创建时间*/
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createAt;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java
@@ -1225,4 +1225,51 @@
     */
    @PostMapping("/common/data/company/export")
    R exportRealCompany(ExportRealCompanyExcelDTO exportRealCompanyExcelDTO);
    /**
     * 社区后台实有单位管理列表
     * @param pageComMngRealAssetsDTO
     * @return
     */
    @PostMapping("/common/data/assets/page")
    R pageQueryComMngRealAssets(@RequestBody PageComMngRealAssetsDTO pageComMngRealAssetsDTO);
    /**
     * 社区后台添加修改实有单位
     * @param comMngRealAssetsVO
     * @return
     */
    @PostMapping("/common/data/assets/save")
    R saveComMngRealAssets(@RequestBody ComMngRealAssetsVO comMngRealAssetsVO);
    /**
     * 社区后台删除实有单位
     * @param id
     * @return
     */
    @DeleteMapping("/common/data/assets/delete")
    R deleteComMngRealAssets(@RequestParam(value = "id") Long id);
    /**
     * 实有单位详情
     * @param id
     * @return
     */
    @GetMapping("/common/data/assets/detail")
    R detailComMngRealAssets(@RequestParam(value = "id") Long id);
    /**
     * 批量导入实有单位
     * @param list 实有单位集合
     */
    @PostMapping("/common/data/assets/import")
    R listSaveMngRealAssetsExcelVO(@RequestBody List<ComMngRealAssetsExcelVO> list,@RequestParam("communityId") Long communityId);
    /**
     * 实有单位导出
     * @param exportRealAssetsExcelDTO
     * @return
     */
    @PostMapping("/common/data/assets/export")
    R exportRealAssets(ExportRealAssetsExcelDTO exportRealAssetsExcelDTO);
}
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/CommonDataApi.java
@@ -10,6 +10,7 @@
import com.jcraft.jsch.SftpException;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.listen.ComMngCarExcelListen;
import com.panzhihua.common.listen.ComMngRealAssetsExcelListen;
import com.panzhihua.common.listen.ComMngRealCompanyExcelListen;
import com.panzhihua.common.model.dtos.community.*;
import com.panzhihua.common.model.dtos.user.*;
@@ -66,6 +67,8 @@
    private String carUrl="http://panzhihua.nhys.cdnhxx.com/web/%e8%bd%a6%e8%be%86%e5%af%bc%e5%85%a5%e6%a8%a1%e6%9d%bf.xlsx";
    @Value("${excel.companyUrl}")
    private String companyUrl="http://panzhihua.nhys.cdnhxx.com/web/%e5%ae%9e%e6%9c%89%e5%8d%95%e4%bd%8d%e5%af%bc%e5%85%a5%e6%a8%a1%e6%9d%bf.xlsx";
    @Value("${excel.assetsUrl}")
    private String assetsUrl="http://panzhihua.nhys.cdnhxx.com/web/%e5%ae%9e%e6%9c%89%e5%8d%95%e4%bd%8d%e5%af%bc%e5%85%a5%e6%a8%a1%e6%9d%bf.xlsx";
    // FTP 登录用户名
    @Value("${ftp.username}")
@@ -234,7 +237,7 @@
    @GetMapping("/user/areas")
    public R listAreas() {
        Long communityId = this.getCommunityId();
        return communityService.listAreas(null,communityId);
        return communityService.listAreas("",communityId);
    }
    @ApiOperation(value = "居民管理 分页查询居民列表",response =InputUserInfoVO.class )
@@ -457,4 +460,110 @@
        }
        return R.fail("未查询到用户");
    }
    /////////////
    @ApiOperation(value = "分页查询实有资产列表",response = ComMngRealAssetsVO.class)
    @PostMapping("/assets/page")
    public R pageQueryComMngRealAssets(@RequestBody PageComMngRealAssetsDTO pageComMngRealAssetsDTO) {
        return communityService.pageQueryComMngRealAssets(pageComMngRealAssetsDTO);
    }
    @ApiOperation(value = "添加/修改实有资产")
    @PostMapping("/assets/save")
    public R saveComMngRealAssets(@RequestBody ComMngRealAssetsVO comMngRealAssetsVO) {
        Long communityId = this.getCommunityId();
        comMngRealAssetsVO.setCommunityId(communityId);
        return communityService.saveComMngRealAssets(comMngRealAssetsVO);
    }
    @ApiOperation(value = "社区后台删除实有资产")
    @DeleteMapping("/assets/delete")
    public R deleteComMngRealAssets(@RequestParam(value = "id") Long id) {
        return communityService.deleteComMngRealAssets(id);
    }
    @ApiOperation(value = "实有资产详情",response = ComMngRealAssetsVO.class)
    @GetMapping("/assets/detail")
    public R detailComMngRealAssets(@RequestParam(value = "id") Long id) {
        return communityService.detailComMngRealAssets(id);
    }
    @ApiOperation(value = "下载模板-实有资产导入模板")
    @GetMapping(value = "/assets/download/template")
    public R downloadRealAssetsTemplate(HttpServletResponse response) throws IOException, SftpException {
        return R.ok(assetsUrl);
    }
    @ApiOperation(value = "excel导入实有资产信息")
    @PostMapping(value = "/assets/import", consumes = "multipart/*", headers = "content-type=multipart/form-date")
    public R importRealAssets(@RequestParam MultipartFile file, HttpServletRequest request) {
        String fileName = file.getOriginalFilename();  //获取文件名
        log.info("传入文件名字【{}】",fileName);
        InputStream inputStream = null;
        try {
            inputStream = file.getInputStream();
            EasyExcel.read(inputStream, ComMngRealAssetsExcelVO.class, new ComMngRealAssetsExcelListen(communityService,this.getCommunityId())).sheet().doRead();
        } catch (IOException e) {
            e.printStackTrace();
            log.error("导入模板失败【{}】", e.getMessage());
        }
        return R.ok();
    }
    @ApiOperation(value = "实有资产Excel" )
    @PostMapping("/assets/export")
    public R exportRealAssets(@RequestBody ExportRealAssetsExcelDTO exportRealAssetsExcelDTO){
        exportRealAssetsExcelDTO.setCommunityId(this.getCommunityId());
        String url=excelUrl;
        String uuid= UUID.randomUUID().toString().replace("-","");
        String name=uuid+".xlsx";
        String ftpUrl="/mnt/data/web/excel/";
//        用户搜索了就下载搜索的用户否则下载所有用户
        R r=communityService.exportRealAssets(exportRealAssetsExcelDTO);
        if (R.isOk(r)) {
            List<ComMngRealAssetsExcelVO>eexcelUserDTOS= JSONArray.parseArray(JSONArray.toJSONString(r.getData()),ComMngRealAssetsExcelVO.class);
            try {
                SFTPUtil sftp = new SFTPUtil(userName,password,host,port);
                sftp.login();
                boolean existDir = sftp.isExistDir(ftpUrl+name);
                if (!existDir) {
                    String property = System.getProperty("user.dir");
                    String fileName = property + File.separator+name;
                    // 这里 需要指定写用哪个class去写
                    ExcelWriter excelWriter = null;
                    InputStream inputStream=null;
                    try {
                        excelWriter = EasyExcel.write(fileName, ComMngRealAssetsExcelVO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build();
                        WriteSheet writeSheet = EasyExcel.writerSheet("实有单位导出").build();
                        excelWriter.write(eexcelUserDTOS, writeSheet);
                        excelWriter.finish();
                        File file=new File(fileName);
                        inputStream=new FileInputStream(file);
                        sftp.uploadMore(ftpUrl, name, inputStream);
                        sftp.logout();
                        inputStream.close();
                        String absolutePath = file.getAbsolutePath();
                        boolean delete = file.delete();
                        log.info("删除excel【{}】结果【{}】",absolutePath,delete);
                    } finally {
                        // 千万别忘记finish 会帮忙关闭流
                        if (inputStream != null) {
                            inputStream.close();
                        }
                        if (excelWriter != null) {
                            excelWriter.finish();
                        }
                    }
                }
                return R.ok(url+name);
            } catch (Exception e) {
                e.printStackTrace();
                log.error("文件传输失败【{}】", e.getMessage());
                return R.fail();
            }
        }
        return R.fail("未查询到用户");
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommonDataApi.java
@@ -2,11 +2,9 @@
import com.panzhihua.common.model.dtos.community.*;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComCvtServeExcelVO;
import com.panzhihua.common.model.vos.community.ComMngCarExcelVO;
import com.panzhihua.common.model.vos.community.ComMngRealCompanyExcelVO;
import com.panzhihua.common.model.vos.community.ComMngRealCompanyVO;
import com.panzhihua.common.model.vos.community.*;
import com.panzhihua.service_community.service.ComMngCarService;
import com.panzhihua.service_community.service.ComMngRealAssetsService;
import com.panzhihua.service_community.service.ComMngRealCompanyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
@@ -29,6 +27,9 @@
    @Resource
    private ComMngRealCompanyService comMngRealCompanyService;
    @Resource
    private ComMngRealAssetsService comMngRealAssetsService;
    /**
     * 小程序用户车辆登记
@@ -145,4 +146,61 @@
    public R exportRealCompanyExcel(@RequestBody ExportRealCompanyExcelDTO exportRealCompanyExcelDTO ){
        return comMngRealCompanyService.exportRealCompanyExcel(exportRealCompanyExcelDTO);
    }
    /**
     * 社区后台实有资产管理列表
     * @param pageComMngRealAssetsDTO
     * @return
     */
    @PostMapping("/assets/page")
    public R pageQueryComMngRealAssets(@RequestBody PageComMngRealAssetsDTO pageComMngRealAssetsDTO) {
        return comMngRealAssetsService.pageQueryComMngRealAssets(pageComMngRealAssetsDTO);
    }
    /**
     * 社区后台添加修改实有资产
     * @param comMngRealAssetsVO
     * @return
     */
    @PostMapping("/assets/save")
    public R saveComMngRealAssets(@RequestBody ComMngRealAssetsVO comMngRealAssetsVO) {
        return comMngRealAssetsService.saveComMngRealAssets(comMngRealAssetsVO);
    }
    /**
     * 社区后台删除实有资产
     * @param id
     * @return
     */
    @DeleteMapping("/assets/delete")
    public R deleteComMngRealAssets(@RequestParam(value = "id") Long id) {
        return comMngRealAssetsService.deleteComMngRealAssets(id);
    }
    @GetMapping("/assets/detail")
    public R detailComMngRealAssets(@RequestParam(value = "id") Long id) {
        return comMngRealAssetsService.detailComMngRealAssets(id);
    }
    /**
     * 社区后台导入实有资产
     * @param list 车实有资产列表
     * @param communityId 社区编号
     * @return
     */
    @PostMapping("/assets/import")
    public R listSaveMngRealAssetsExcelVO(@RequestBody List<ComMngRealAssetsExcelVO> list, @RequestParam("communityId") Long communityId){
        return comMngRealAssetsService.listSaveMngRealAssetsExcelVO(list,communityId);
    }
    /**
     * 导出实有资产
     * @param exportRealAssetsExcelDTO 实有资产导出查询参数
     * @return
     */
    @PostMapping("/assets/export")
    public R exportRealAssetsExcel(@RequestBody ExportRealAssetsExcelDTO exportRealAssetsExcelDTO ){
        return comMngRealAssetsService.exportRealAssetsExcel(exportRealAssetsExcelDTO);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngCarDAO.java
@@ -46,8 +46,8 @@
            "<if test='pageComMngCarDTO.communityId != null and pageComMngCarDTO.communityId != 0'>" +
            " and t.community_id = #{pageComMngCarDTO.communityId} " +
            " </if> " +
            "<if test='pageComMngCarDTO.areaId != null and pageComMngCarDTO.areaId != 0'>" +
            " and t.area_id = #{pageComMngCarDTO.areaId} " +
            "<if test='pageComMngCarDTO.areaName != null and pageComMngCarDTO.areaName != 0'>" +
            " and t2.area_name LIKE concat( #{pageComMngCarDTO.areaName}, '%' )  " +
            " </if> " +
            " order by t.create_at desc"+
            "</script>")
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngRealAssetsDAO.java
New file
@@ -0,0 +1,80 @@
package com.panzhihua.service_community.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.model.dtos.community.ExportRealAssetsExcelDTO;
import com.panzhihua.common.model.dtos.community.ExportRealCompanyExcelDTO;
import com.panzhihua.common.model.dtos.community.PageComMngRealAssetsDTO;
import com.panzhihua.common.model.dtos.community.PageComMngRealCompanyDTO;
import com.panzhihua.common.model.vos.community.ComMngRealAssetsExcelVO;
import com.panzhihua.common.model.vos.community.ComMngRealAssetsVO;
import com.panzhihua.common.model.vos.community.ComMngRealCompanyExcelVO;
import com.panzhihua.common.model.vos.community.ComMngRealCompanyVO;
import com.panzhihua.service_community.model.dos.ComMngRealAssetsDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
 * @description: 实有资产
 * @author: Null
 * @date: 2021/3/16 14:28
 */
@Mapper
public interface ComMngRealAssetsDAO extends BaseMapper<ComMngRealAssetsDO> {
    @Select("<script> " +
            "SELECT " +
            " t.id, " +
            " t.community_id AS communityId, " +
            " t.`name`, " +
            " t.category, " +
            " t.build_type_id AS buildTypeId, " +
            " t2.`name` AS buildTypeName, " +
            " t.floor_type AS floorType, " +
            " t.num, " +
            " t.square, " +
            " t.province_adcode AS provinceAdcode, " +
            " t.city_adcode AS cityAdcode, " +
            " t.district_adcode AS districtAdcode, " +
            " t.address, " +
            " t.create_at AS createAt  " +
            "FROM " +
            " com_mng_real_assets t " +
            " LEFT JOIN com_mng_struct_build_type t2 ON t.build_type_id = t2.id" +
            " WHERE 1= 1 " +
            "<if test='pageComMngRealAssetsDTO.name != null and pageComMngRealAssetsDTO.name.trim() != &quot;&quot;'>" +
            " and t.name LIKE concat( #{pageComMngRealAssetsDTO.name}, '%' )  " +
            " </if> " +
            "<if test='pageComMngRealAssetsDTO.communityId != null and pageComMngRealAssetsDTO.communityId != 0'>" +
            " and t.community_id = #{pageComMngRealCompanyDTO.communityId} " +
            " </if> " +
            " order by t.create_at desc"+
            "</script>")
    IPage<ComMngRealAssetsVO> pageQueryComMngRealAssets(Page page, @Param(value = "pageComMngRealAssetsDTO") PageComMngRealAssetsDTO pageComMngRealAssetsDTO);
    @Select("<script> " +
            " SELECT " +
            " t.`name`, " +
            " case t.category when 1 then '建筑类'  when 2 then '公共设施类' else '/' end category,  " +
            " t2.`name` AS buildTypeName, " +
            " case t.floor_type when 1 then '高层'  when 2 then '中层'  when 3 then '低层' else '/' end floorType,  " +
            " t.num, " +
            " t.square, " +
            " t.address " +
            "FROM " +
            " com_mng_real_assets t " +
            " LEFT JOIN com_mng_struct_build_type t2 ON t.build_type_id = t2.id"+
            "<if test='exportRealAssetsExcelDTO.name != null and exportRealAssetsExcelDTO.name.trim() != &quot;&quot;'>" +
            " and t.name LIKE concat( #{exportRealAssetsExcelDTO.name}, '%' )  " +
            " </if> " +
            "<if test='exportRealAssetsExcelDTO.communityId != null and exportRealAssetsExcelDTO.communityId != 0'>" +
            " and t.community_id = #{exportRealAssetsExcelDTO.communityId} " +
            " </if> " +
            " order by t.create_at desc"+
            "</script>")
    List<ComMngRealAssetsExcelVO> exportRealAssetsExcel(@Param(value = "exportRealAssetsExcelDTO") ExportRealAssetsExcelDTO exportRealAssetsExcelDTO);
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ComMngRealAssetsDO.java
New file
@@ -0,0 +1,62 @@
package com.panzhihua.service_community.model.dos;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
 * @description: 实有资产
 * @author: Null
 * @date: 2021/3/19 15:43
 */
@Data
@TableName(value = "com_mng_real_assets")
public class ComMngRealAssetsDO implements Serializable {
    /**主键*/
    @TableId(type = IdType.AUTO)
    private Long id;
    /**社区ID*/
    private Long communityId;
    /**资产名称*/
    private String name;
    /**分类:1-建筑类 2-公共设施类*/
    private Integer category;
    /**建筑类型ID*/
    private Long buildTypeId;
    /**楼层类型:1-高层 2-中层 3-底层*/
    private Integer floorType;
    /**数量*/
    private Integer num;
    /**面积*/
    private BigDecimal square;
    /**省份行政区划代码*/
    private Integer provinceAdcode;
    /**城市行政区划代码*/
    private Integer cityAdcode;
    /**区县行政区划代码*/
    private Integer districtAdcode;
    /**详细地址*/
    private String address;
    /**创建时间*/
    @TableField(fill = FieldFill.INSERT)
    private Date createAt;
    /**创建人*/
    private Long createBy;
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngRealAssetsService.java
New file
@@ -0,0 +1,59 @@
package com.panzhihua.service_community.service;
import com.panzhihua.common.model.dtos.community.ExportRealAssetsExcelDTO;
import com.panzhihua.common.model.dtos.community.ExportRealCompanyExcelDTO;
import com.panzhihua.common.model.dtos.community.PageComMngRealAssetsDTO;
import com.panzhihua.common.model.dtos.community.PageComMngRealCompanyDTO;
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.model.vos.community.ComMngRealCompanyExcelVO;
import com.panzhihua.common.model.vos.community.ComMngRealCompanyVO;
import java.util.List;
public interface ComMngRealAssetsService {
    /**
     * 社区后台实有资产管理列表
     * @param pageComMngRealAssetsDTO
     * @return
     */
    R pageQueryComMngRealAssets(PageComMngRealAssetsDTO pageComMngRealAssetsDTO);
    /**
     * 社区后台添加修改实有资产
     * @param comMngRealAssetsVO
     * @return
     */
    R saveComMngRealAssets(ComMngRealAssetsVO comMngRealAssetsVO);
    /**
     * 社区后台删除实有资产
     * @param id
     * @return
     */
    R deleteComMngRealAssets(Long id);
    /**
     * 实有资产详情
     * @param id
     * @return
     */
    R detailComMngRealAssets(Long id);
    /**
     * 导入实有资产
     * @param list
     * @param communityId
     * @return
     */
    R listSaveMngRealAssetsExcelVO(List<ComMngRealAssetsExcelVO> list, Long communityId);
    /**
     * 导出实有资产
     * @param exportRealAssetsExcelDTO
     * @return
     */
    R exportRealAssetsExcel(ExportRealAssetsExcelDTO exportRealAssetsExcelDTO);
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngRealAssetsServiceImpl.java
New file
@@ -0,0 +1,116 @@
package com.panzhihua.service_community.service.impl;
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.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.service_community.dao.ComMngRealAssetsDAO;
import com.panzhihua.service_community.model.dos.ComMngRealAssetsDO;
import com.panzhihua.service_community.service.ComMngRealAssetsService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
 * @description: 实有资产
 * @author: Null
 * @date: 2021/3/19 11:55
 */
@Service
public class ComMngRealAssetsServiceImpl extends ServiceImpl<ComMngRealAssetsDAO, ComMngRealAssetsDO>  implements ComMngRealAssetsService {
    @Resource
    private ComMngRealAssetsDAO comMngRealAssetsDAO;
    @Override
    public R pageQueryComMngRealAssets(PageComMngRealAssetsDTO pageComMngRealAssetsDTO) {
        Page page = new Page<>();
        Long pageNum = pageComMngRealAssetsDTO.getPageNum();
        Long pageSize = pageComMngRealAssetsDTO.getPageSize();
        if (null == pageNum || 0 == pageNum) {
            pageNum = 1l;
        }
        if (null == pageSize || 0 == pageSize) {
            pageSize = 10l;
        }
        page.setSize(pageSize);
        page.setCurrent(pageNum);
        IPage<ComMngRealAssetsVO> iPage = comMngRealAssetsDAO.pageQueryComMngRealAssets(page, pageComMngRealAssetsDTO);
        return R.ok(iPage);
    }
    @Override
    public R saveComMngRealAssets(ComMngRealAssetsVO comMngRealAssetsVO) {
        if(null!=comMngRealAssetsVO.getId() && comMngRealAssetsVO.getId()!=0){
            //修改
            ComMngRealAssetsDO comMngRealAssetsDO = comMngRealAssetsDAO.selectById(comMngRealAssetsVO.getId());
            BeanUtils.copyProperties(comMngRealAssetsVO,comMngRealAssetsDO);
            int update = comMngRealAssetsDAO.updateById(comMngRealAssetsDO);
            if(update>0){
                return R.ok();
            }
        }else{
            ComMngRealAssetsDO comMngRealAssetsDO = new ComMngRealAssetsDO();
            BeanUtils.copyProperties(comMngRealAssetsVO,comMngRealAssetsDO);
            int insert = comMngRealAssetsDAO.insert(comMngRealAssetsDO);
            if(insert>0){
                return R.ok();
            }
        }
        return R.fail("添加失败");
    }
    @Override
    public R deleteComMngRealAssets(Long id) {
        ComMngRealAssetsDO comMngRealAssetsDO = comMngRealAssetsDAO.selectById(id);
        if(null==comMngRealAssetsDO){
            return R.fail("该资产不存在");
        }
        int delete = comMngRealAssetsDAO.deleteById(id);
        if(delete>0){
            return R.ok();
        }
        return R.fail("删除失败");
    }
    @Override
    public R detailComMngRealAssets(Long id) {
        ComMngRealAssetsDO comMngRealAssetsDO = comMngRealAssetsDAO.selectById(id);
        if(null==comMngRealAssetsDO){
            return R.fail("该资产不存在");
        }
        ComMngRealAssetsVO comMngRealAssetsVO = new 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->{
            ComMngRealAssetsDO comMngRealAssetsDO = new ComMngRealAssetsDO();
            BeanUtils.copyProperties(l,comMngRealAssetsDO);
            comMngRealAssetsDO.setCommunityId(communityId);
            comMngRealAssetsDOS.add(comMngRealAssetsDO);
        });
        boolean batch = this.saveBatch(comMngRealAssetsDOS);
        if(batch){
            return R.ok();
        }
        return R.fail("请检查数据是否重复,格合是否正确");
    }
    @Override
    public R exportRealAssetsExcel(ExportRealAssetsExcelDTO exportRealAssetsExcelDTO) {
        List<ComMngRealAssetsExcelVO> list = comMngRealAssetsDAO.exportRealAssetsExcel(exportRealAssetsExcelDTO);
        return R.ok(list);
    }
}