Browse Source

用户管理导入功能开发

huangpeng 2 months ago
parent
commit
ada621cc5d
21 changed files with 793 additions and 0 deletions
  1. 18 0
      zhsw-common/src/main/java/com/rongwei/zhsw/system/dao/SwBookManagementDao.java
  2. 32 0
      zhsw-common/src/main/java/com/rongwei/zhsw/system/dao/SwPreferentialUserCategoriesDao.java
  3. 3 0
      zhsw-common/src/main/java/com/rongwei/zhsw/system/dao/SwUserManagementDao.java
  4. 32 0
      zhsw-common/src/main/java/com/rongwei/zhsw/system/dao/SwWaterPriceManagementDao.java
  5. 227 0
      zhsw-common/src/main/java/com/rongwei/zhsw/system/importListener/UserManagementRecordListener.java
  6. 16 0
      zhsw-common/src/main/java/com/rongwei/zhsw/system/service/SwBookManagementService.java
  7. 19 0
      zhsw-common/src/main/java/com/rongwei/zhsw/system/service/SwPreferentialUserCategoriesService.java
  8. 20 0
      zhsw-common/src/main/java/com/rongwei/zhsw/system/service/SwWaterPriceManagementService.java
  9. 39 0
      zhsw-common/src/main/java/com/rongwei/zhsw/system/service/impl/ImportExcelServiceImpl.java
  10. 20 0
      zhsw-common/src/main/java/com/rongwei/zhsw/system/service/impl/SwBookManagementServiceImpl.java
  11. 30 0
      zhsw-common/src/main/java/com/rongwei/zhsw/system/service/impl/SwPreferentialUserCategoriesServiceImpl.java
  12. 5 0
      zhsw-common/src/main/java/com/rongwei/zhsw/system/service/impl/SwUserManagementServiceImpl.java
  13. 25 0
      zhsw-common/src/main/java/com/rongwei/zhsw/system/service/impl/SwWaterPriceManagementServiceImpl.java
  14. 69 0
      zhsw-entity/src/main/java/com/rongwe/zhsw/system/domain/SwBookManagementDo.java
  15. 58 0
      zhsw-entity/src/main/java/com/rongwe/zhsw/system/domain/SwPreferentialUserCategoriesDo.java
  16. 14 0
      zhsw-entity/src/main/java/com/rongwe/zhsw/system/domain/SwUserManagementDo.java
  17. 66 0
      zhsw-entity/src/main/java/com/rongwe/zhsw/system/domain/SwWaterPriceManagementDo.java
  18. 67 0
      zhsw-entity/src/main/java/com/rongwe/zhsw/system/vo/ImportUserManagementRecordVo.java
  19. 13 0
      zhsw-entity/src/main/java/com/rongwe/zhsw/system/vo/SwPreferentialUserCategoriesVo.java
  20. 13 0
      zhsw-entity/src/main/java/com/rongwe/zhsw/system/vo/SwWaterPriceManagementVo.java
  21. 7 0
      zhsw-server/src/main/java/com/rongwei/zhsw/system/controller/ImportExcelController.java

+ 18 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/dao/SwBookManagementDao.java

@@ -0,0 +1,18 @@
+package com.rongwei.zhsw.system.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.rongwe.zhsw.system.domain.SwBookManagementDo;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 册号管理(SwBookManagement)表数据库访问层
+ *
+ * @author makejava
+ * @since 2025-06-04 16:24:19
+ */
+
+    @Mapper
+    public interface SwBookManagementDao extends BaseMapper<SwBookManagementDo> {
+
+}
+

+ 32 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/dao/SwPreferentialUserCategoriesDao.java

@@ -0,0 +1,32 @@
+package com.rongwei.zhsw.system.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.rongwe.zhsw.system.domain.SwPreferentialUserCategoriesDo;
+import com.rongwe.zhsw.system.vo.SwPreferentialUserCategoriesVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+/**
+ * 优惠用户类别(SwPreferentialUserCategories)表数据库访问层
+ *
+ * @author makejava
+ * @since 2025-06-04 16:27:10
+ */
+@Mapper
+public interface SwPreferentialUserCategoriesDao extends BaseMapper<SwPreferentialUserCategoriesDo> {
+
+    @Select("SELECT\n" +
+            "\ta.DISCOUNTTYPE,a.ID,\n" +
+            "\ta.DISCOUNTWATER ,\n" +
+            "\ta.MONTHLYWATERDISCOUNT,\n" +
+            "\tb.`NAME` 'DISCOUNTTYPENAME'\n" +
+            "FROM\n" +
+            "\tsw_preferential_user_categories a \n" +
+            "\tLEFT JOIN sys_dict b on a.DISCOUNTTYPE =b.`VALUE`  and b.DELETED ='0' and b.DICTTYPE='sw_yhlb'\n" +
+            "WHERE\n" +
+            "\ta.DELETED = '0' \n")
+    List<SwPreferentialUserCategoriesVo> selectUserType();
+}
+

+ 3 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/dao/SwUserManagementDao.java

@@ -3,6 +3,7 @@ package com.rongwei.zhsw.system.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.rongwe.zhsw.system.domain.SwUserManagementDo;
+import com.rongwe.zhsw.system.domain.SwWaterUsageEntryDo;
 import com.rongwe.zhsw.system.dto.TransferAccountDo;
 import com.rongwe.zhsw.system.vo.SwUserManagementVo;
 import org.apache.ibatis.annotations.Mapper;
@@ -39,6 +40,8 @@ public interface SwUserManagementDao extends BaseMapper<SwUserManagementDo> {
 
     SwUserManagementVo getDataByAccountName(@Param("huHao") String huHao, @Param("waterCompanyId") String waterCompanyId);
 
+
+
 }
 
 

+ 32 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/dao/SwWaterPriceManagementDao.java

@@ -0,0 +1,32 @@
+package com.rongwei.zhsw.system.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.rongwe.zhsw.system.domain.SwWaterPriceManagementDo;
+import com.rongwe.zhsw.system.vo.SwWaterPriceManagementVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+/**
+ * 水价管理(SwWaterPriceManagement)表数据库访问层
+ *
+ * @author makejava
+ * @since 2025-06-04 16:24:22
+ */
+@Mapper
+public interface SwWaterPriceManagementDao extends BaseMapper<SwWaterPriceManagementDo> {
+
+    @Select("SELECT\n" +
+            "\ta.WATERTYPE,\n" +
+            "\ta.PRICE ,\n" +
+            "\tb.`NAME` 'WATERTYPENAME'\n" +
+            "FROM\n" +
+            "\tsw_water_price_management a \n" +
+            "\tLEFT JOIN sys_dict b on a.WATERTYPE =b.`VALUE`  and b.DELETED ='0' and b.DICTTYPE='water-use-type'\n" +
+            "WHERE\n" +
+            "\ta.DELETED = '0' \n" +
+            "\tAND a.STATUS = 'enable'")
+    List<SwWaterPriceManagementVo> selectWatertype();
+}
+

+ 227 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/importListener/UserManagementRecordListener.java

@@ -0,0 +1,227 @@
+package com.rongwei.zhsw.system.importListener;
+
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.rongwe.zhsw.system.domain.SwBookManagementDo;
+import com.rongwe.zhsw.system.domain.SwUserManagementDo;
+import com.rongwe.zhsw.system.vo.ImportUserManagementRecordVo;
+import com.rongwe.zhsw.system.vo.SwPreferentialUserCategoriesVo;
+import com.rongwe.zhsw.system.vo.SwWaterPriceManagementVo;
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
+import com.rongwei.rwcommon.base.exception.CustomException;
+import com.rongwei.rwcommon.utils.SecurityUtil;
+import com.rongwei.zhsw.system.service.SwBookManagementService;
+import com.rongwei.zhsw.system.service.SwPreferentialUserCategoriesService;
+import com.rongwei.zhsw.system.service.SwWaterPriceManagementService;
+import com.rongwei.zhsw.system.service.impl.SwBookManagementServiceImpl;
+import com.rongwei.zhsw.system.service.impl.SwPreferentialUserCategoriesServiceImpl;
+import com.rongwei.zhsw.system.service.impl.SwUserManagementServiceImpl;
+import com.rongwei.zhsw.system.service.impl.SwWaterPriceManagementServiceImpl;
+import com.rongwei.zhsw.system.utils.ZHSWCommonUtils;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static com.rongwei.zhsw.system.utils.ZHSWCommonUtils.getCurrentUser;
+
+public class UserManagementRecordListener extends AnalysisEventListener<ImportUserManagementRecordVo> {
+
+    private static final Logger log = LoggerFactory.getLogger(UserManagementRecordListener.class);
+    private List<ImportUserManagementRecordVo> recordList = new ArrayList<>();
+    private List<SwUserManagementDo> saveList = new ArrayList<>();
+
+    private SwUserManagementServiceImpl swUserManagementService;
+
+    private SwBookManagementService swBookManagementService;
+
+    private SwPreferentialUserCategoriesService swPreferentialUserCategoriesService;
+
+    private SwWaterPriceManagementService  swWaterPriceManagementService;
+
+
+    // 出现重复记录的数据
+    private List<ImportUserManagementRecordVo> duplicateRecordList = new ArrayList<>();
+
+    public UserManagementRecordListener(SwUserManagementServiceImpl userManagementService,
+                                        SwPreferentialUserCategoriesServiceImpl preferentialUserCategoriesService,
+                                        SwBookManagementServiceImpl bookManagementService, SwWaterPriceManagementServiceImpl waterPriceManagementService) {
+        this.swUserManagementService = userManagementService;
+        this.swBookManagementService = bookManagementService;
+        this.swPreferentialUserCategoriesService = preferentialUserCategoriesService;
+        this.swWaterPriceManagementService = waterPriceManagementService;
+    }
+
+
+    /**
+     * 导入前数据校验
+     * @param importUserManagementRecordVo
+     * @param analysisContext
+     */
+    @Override
+    public void invoke(ImportUserManagementRecordVo importUserManagementRecordVo, AnalysisContext analysisContext) {
+       // Integer currentRowNum = analysisContext.readRowHolder().getRowIndex();
+        if (StringUtils.isBlank(importUserManagementRecordVo.getUsernumber())) {
+            return;
+
+        }
+
+        // 判断数据是否重复
+        boolean b = recordList.stream().anyMatch(record -> record.getUsernumber().
+                equals(importUserManagementRecordVo.getUsernumber()));
+        if (b) {
+            duplicateRecordList.add(importUserManagementRecordVo);
+            throw new CustomException("户号重复:"+importUserManagementRecordVo.getUsernumber());
+          //  return;
+        }
+        recordList.add(importUserManagementRecordVo);
+    }
+
+    @Override
+    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+//        if (!duplicateRecordList.isEmpty()) {
+//            throw new CustomException(
+//                    "Excel表中存在相同户号,请检查! 户号为:" +
+//                            duplicateRecordList.stream().map(ImportUserManagementRecordVo::getUsernumber).collect(Collectors.joining("、")));
+//        }
+        if (recordList.isEmpty()) {
+            return;
+        }
+
+        // 获取数据中的所有户号 ,数据匹配范围(启用 + 停用)
+        List<String> statusList = new ArrayList<>(Arrays.asList("enable","disable"));
+        List<String> accountNumList = recordList.stream().map(ImportUserManagementRecordVo::getUsernumber).distinct().
+                collect(Collectors.toList());
+        List<SwUserManagementDo> repeatDataList = swUserManagementService.list(new LambdaQueryWrapper<SwUserManagementDo>()
+                .in(SwUserManagementDo::getUsernumber, accountNumList).eq(SwUserManagementDo::getDeleted, "0")
+                .in(SwUserManagementDo::getStatus,statusList));
+        if(!repeatDataList.isEmpty()){
+            throw new CustomException(
+                   repeatDataList.stream().map(SwUserManagementDo::getUsernumber).distinct().
+                           collect(Collectors.joining("、"))+" 户号已存在,请检查后重新导入"
+            );
+        }
+        //查询册号数据
+        Map<String, List<SwBookManagementDo>> volumenoMap =new HashMap<>();
+        try {
+            volumenoMap =swBookManagementService.list(new LambdaQueryWrapper<SwBookManagementDo>().
+                            eq(SwBookManagementDo::getDeleted, "0").eq(SwBookManagementDo::getStatus, "enable"))
+              .stream().collect(Collectors.groupingBy(info -> info.getBooknumber()));
+        }catch (Exception e){
+            throw new CustomException(
+                  "册号存在相同记录,请联系管理员"
+            );
+        }
+        //查询用水类型数据
+        Map<String, List<SwWaterPriceManagementVo>> watertypeMap = swWaterPriceManagementService.selectWatertype().stream().
+                collect(Collectors.groupingBy(info -> info.getWatertypename()));
+
+        //查询用户类别数据
+        Map<String, List<SwPreferentialUserCategoriesVo>> usertypeMap = swPreferentialUserCategoriesService.selectUserType().stream().
+                collect(Collectors.groupingBy(info -> info.getDiscounttypename()));
+
+        setRecordData(volumenoMap,watertypeMap,usertypeMap);
+
+    }
+
+    public  void setRecordData(Map<String, List<SwBookManagementDo>> volumenoMap, Map<String, List<SwWaterPriceManagementVo>> watertypeMap, Map<String, List<SwPreferentialUserCategoriesVo>> usertypeMap){
+        // 当前导入用户的操作人
+        SysUserVo currentUser = getCurrentUser();
+        Date date = new Date();
+        SwUserManagementDo saveUserDo=null;
+        BigDecimal meterMaxValue = new BigDecimal("9999");
+        BigDecimal zero = BigDecimal.ZERO;
+        for (ImportUserManagementRecordVo recordVo:recordList){
+            saveUserDo = new SwUserManagementDo();
+            saveUserDo.setId(SecurityUtil.getUUID());
+            saveUserDo.setUsernumber(recordVo.getUsernumber());
+            saveUserDo.setUsername(recordVo.getUsername());
+            saveUserDo.setStatus("enable");
+
+            saveUserDo.setAccountbalance(recordVo.getAccountbalance());
+            saveUserDo.setBldg(recordVo.getBldg());
+            saveUserDo.setUnitnum(recordVo.getUnitnum());
+            saveUserDo.setHouseno(recordVo.getHouseno());
+            //METERMAXVALUE   表具最大读数  默认=9999
+            saveUserDo.setMetermaxvalue(meterMaxValue);
+            //LASTMETERREADDATE  最近抄表日期  默认=  当前日期
+            saveUserDo.setLastmeterreaddate(date);
+            //LASTMETERREADING   最近抄表读数  默认= 0
+            saveUserDo.setLastmeterreading(zero);
+
+            //册号
+            saveUserDo.setVolumeno(recordVo.getVolumeno());
+            saveUserDo.setVolumenoid(Optional.ofNullable(volumenoMap.get(recordVo.getVolumeno()))
+                    .orElse(new ArrayList<>())
+                    .stream()
+                    .findFirst()
+                    .map(SwBookManagementDo::getId)
+                    .orElse(null));
+            saveUserDo.setVillagename(Optional.ofNullable(volumenoMap.get(recordVo.getVolumeno()))
+                    .orElse(new ArrayList<>())
+                    .stream()
+                    .findFirst()
+                    .map(SwBookManagementDo::getVillagename)
+                    .orElse(null));
+            saveUserDo.setAddress(recordVo.getAddress());
+            saveUserDo.setPhonenumber(recordVo.getPhonenumber());
+
+           //用水类型
+            saveUserDo.setWatertype(Optional.ofNullable(watertypeMap.get(recordVo.getWatertypename()))
+                    .orElse(new ArrayList<>())
+                    .stream()
+                    .findFirst()
+                    .map(SwWaterPriceManagementVo::getWatertype)
+                    .orElse(null));
+            //WATERPRICE  水价 根据  用水类型 进行更新为对应价格
+            saveUserDo.setWaterprice(Optional.ofNullable(watertypeMap.get(recordVo.getWatertypename()))
+                    .orElse(new ArrayList<>())
+                    .stream()
+                    .findFirst()
+                    .map(SwWaterPriceManagementVo::getPrice)
+                    .orElse(null));
+
+            //用户类别
+            saveUserDo.setUsertype(Optional.ofNullable(usertypeMap.get(recordVo.getUsertypename()))
+                    .orElse(new ArrayList<>())
+                    .stream()
+                    .findFirst()
+                    .map(SwPreferentialUserCategoriesVo::getDiscounttype)
+                    .orElse(null));
+
+            saveUserDo.setUsertypeid(Optional.ofNullable(usertypeMap.get(recordVo.getUsertypename()))
+                    .orElse(new ArrayList<>())
+                    .stream()
+                    .findFirst()
+                    .map(SwPreferentialUserCategoriesVo::getId)
+                    .orElse(null));
+
+           //EXEMPTIONWATER  减免用水   根据  用户类别 进行更新为对应减免用水
+            saveUserDo.setExemptionamount(Optional.ofNullable(usertypeMap.get(recordVo.getUsertypename()))
+                    .orElse(new ArrayList<>())
+                    .stream()
+                    .findFirst()
+                    .map(SwPreferentialUserCategoriesVo::getMonthlywaterdiscount)
+                    .orElse(null));
+
+               //EXEMPTIONAMOUNT   减免金额   根据  用户类别 进行更新为对应减免金额
+            saveUserDo.setExemptionwater(Optional.ofNullable(usertypeMap.get(recordVo.getUsertypename()))
+                    .orElse(new ArrayList<>())
+                    .stream()
+                    .findFirst()
+                    .map(SwPreferentialUserCategoriesVo::getDiscountwater)
+                    .orElse(null));
+
+            ZHSWCommonUtils.initModelGeneralParameters(saveUserDo, currentUser);
+            saveList.add(saveUserDo);
+        };
+    }
+    // 获取Excel 中的数据
+    public List<SwUserManagementDo> getData() {
+        return saveList;
+    }
+}

+ 16 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/service/SwBookManagementService.java

@@ -0,0 +1,16 @@
+package com.rongwei.zhsw.system.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwe.zhsw.system.domain.SwBookManagementDo;
+
+
+/**
+ * 册号管理(SwBookManagement)表服务接口
+ *
+ * @author makejava
+ * @since 2025-06-04 16:24:21
+ */
+public interface SwBookManagementService extends IService<SwBookManagementDo> {
+
+}
+

+ 19 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/service/SwPreferentialUserCategoriesService.java

@@ -0,0 +1,19 @@
+package com.rongwei.zhsw.system.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwe.zhsw.system.domain.SwPreferentialUserCategoriesDo;
+import com.rongwe.zhsw.system.vo.SwPreferentialUserCategoriesVo;
+
+import java.util.List;
+
+/**
+ * 优惠用户类别(SwPreferentialUserCategories)表服务接口
+ *
+ * @author makejava
+ * @since 2025-06-04 16:27:10
+ */
+public interface SwPreferentialUserCategoriesService extends IService<SwPreferentialUserCategoriesDo> {
+
+    List<SwPreferentialUserCategoriesVo> selectUserType();
+}
+

+ 20 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/service/SwWaterPriceManagementService.java

@@ -0,0 +1,20 @@
+package com.rongwei.zhsw.system.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwe.zhsw.system.domain.SwWaterPriceManagementDo;
+import com.rongwe.zhsw.system.vo.SwWaterPriceManagementVo;
+
+import java.util.List;
+
+/**
+ * 水价管理(SwWaterPriceManagement)表服务接口
+ *
+ * @author makejava
+ * @since 2025-06-04 16:24:23
+ */
+public interface SwWaterPriceManagementService extends IService<SwWaterPriceManagementDo> {
+
+    List<SwWaterPriceManagementVo> selectWatertype();
+
+}
+

+ 39 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/service/impl/ImportExcelServiceImpl.java

@@ -5,13 +5,18 @@ import com.google.common.collect.Lists;
 import com.rongwe.zhsw.system.domain.SwUserManagementDo;
 import com.rongwe.zhsw.system.domain.SwWaterUsageEntryDo;
 import com.rongwe.zhsw.system.vo.ImportMeterReadingRecordVo;
+import com.rongwe.zhsw.system.vo.ImportUserManagementRecordVo;
 import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommoncomponent.file.dao.SysFileItemDao;
 import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
 import com.rongwei.zhsw.system.config.ContextHolder;
 import com.rongwei.zhsw.system.importListener.MeterReadingRecordListener;
+import com.rongwei.zhsw.system.importListener.UserManagementRecordListener;
 import com.rongwei.zhsw.system.service.ImportExcelService;
+import com.rongwei.zhsw.system.service.SwBookManagementService;
+import com.rongwei.zhsw.system.service.SwPreferentialUserCategoriesService;
+import com.rongwei.zhsw.system.service.SwWaterPriceManagementService;
 import com.rongwei.zhsw.system.utils.ZHSWCommonUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.ibatis.session.SqlSessionFactory;
@@ -45,6 +50,13 @@ public class ImportExcelServiceImpl implements ImportExcelService {
     private SwWaterUsageEntryServiceImpl waterUsageEntryService;
     @Autowired
     private BillGenerationServiceImpl billGenerationService;
+    @Autowired
+    private SwBookManagementServiceImpl bookManagementService;
+    @Autowired
+    private SwPreferentialUserCategoriesServiceImpl preferentialUserCategoriesService;
+    @Autowired
+    private SwWaterPriceManagementServiceImpl waterPriceManagementService;
+
     @Autowired
     private SqlSessionFactory sqlSessionFactory;
 
@@ -170,4 +182,31 @@ public class ImportExcelServiceImpl implements ImportExcelService {
         parameterCheck(() -> !file.exists(), "文件解析有误!请联系管理员", "根据文件地址:{},无法获取文件", realPath);
         return file;
     }
+
+    public R userManagement(String fileId) {
+        log.info("开始导入用户记录");
+        File file = readFile(fileId);
+        // 数据读取
+        long startTime = System.currentTimeMillis();
+        UserManagementRecordListener userManagementRecordListener;
+        try {
+            userManagementRecordListener = new UserManagementRecordListener(userManagementService,
+                    preferentialUserCategoriesService,bookManagementService,waterPriceManagementService);
+            EasyExcel.read(file, ImportUserManagementRecordVo.class, userManagementRecordListener).sheet(0).headRowNumber(3).doRead();
+        } catch (Exception e) {
+            return R.error(e.getMessage());
+        }
+
+        // 获取处理之后的数据
+        long entTime = System.currentTimeMillis();
+        log.error("excel解析时长:{}", startTime - entTime);
+        List<SwUserManagementDo> saveList = userManagementRecordListener.getData();
+        if(saveList.isEmpty()) {
+            return  R.error("excel为空或excel中的数据已导入过");
+        }
+
+        userManagementService.saveBatch(saveList,200);
+
+        return R.ok();
+    }
 }

+ 20 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/service/impl/SwBookManagementServiceImpl.java

@@ -0,0 +1,20 @@
+package com.rongwei.zhsw.system.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwe.zhsw.system.domain.SwBookManagementDo;
+import com.rongwei.zhsw.system.dao.SwBookManagementDao;
+import com.rongwei.zhsw.system.service.SwBookManagementService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 册号管理(SwBookManagement)表服务接口
+ *
+ * @author makejava
+ * @since 2025-06-04 16:24:21
+ */
+@Service
+public class SwBookManagementServiceImpl extends ServiceImpl<SwBookManagementDao, SwBookManagementDo>
+        implements SwBookManagementService {
+
+}
+

+ 30 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/service/impl/SwPreferentialUserCategoriesServiceImpl.java

@@ -0,0 +1,30 @@
+package com.rongwei.zhsw.system.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwe.zhsw.system.domain.SwPreferentialUserCategoriesDo;
+import com.rongwe.zhsw.system.vo.SwPreferentialUserCategoriesVo;
+import com.rongwei.zhsw.system.dao.SwPreferentialUserCategoriesDao;
+import com.rongwei.zhsw.system.service.SwPreferentialUserCategoriesService;
+import org.springframework.stereotype.Service;
+
+import java.util.Collections;
+import java.util.List;
+
+
+/**
+ * 优惠用户类别(SwPreferentialUserCategories)表服务接口
+ *
+ * @author makejava
+ * @since 2025-06-04 16:27:10
+ */
+@Service
+public class SwPreferentialUserCategoriesServiceImpl extends ServiceImpl<SwPreferentialUserCategoriesDao, SwPreferentialUserCategoriesDo>
+        implements SwPreferentialUserCategoriesService
+{
+
+    @Override
+    public List<SwPreferentialUserCategoriesVo> selectUserType() {
+        return this.getBaseMapper().selectUserType();
+    }
+}
+

+ 5 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/service/impl/SwUserManagementServiceImpl.java

@@ -3,11 +3,13 @@ package com.rongwei.zhsw.system.service.impl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwe.zhsw.system.domain.SwUserManagementDo;
 import com.rongwe.zhsw.system.dto.TransferAccountDo;
+import com.rongwe.zhsw.system.vo.SwUserManagementVo;
 import com.rongwei.zhsw.system.dao.SwUserManagementDao;
 import com.rongwei.zhsw.system.service.SwUserManagementService;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -34,6 +36,9 @@ public class SwUserManagementServiceImpl extends ServiceImpl<SwUserManagementDao
     public void batchUpdateUserBalances(List<TransferAccountDo.UpdateUserBalance> list) {
         this.getBaseMapper().batchUpdateUserBalances(list);
     }
+
+
+
 }
 
 

+ 25 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/service/impl/SwWaterPriceManagementServiceImpl.java

@@ -0,0 +1,25 @@
+package com.rongwei.zhsw.system.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwe.zhsw.system.domain.SwWaterPriceManagementDo;
+import com.rongwe.zhsw.system.vo.SwWaterPriceManagementVo;
+import com.rongwei.zhsw.system.dao.SwWaterPriceManagementDao;
+import com.rongwei.zhsw.system.service.SwWaterPriceManagementService;
+import org.springframework.stereotype.Service;
+import java.util.List;
+
+/**
+ * 水价管理(SwWaterPriceManagement)表服务接口
+ *
+ * @author makejava
+ * @since 2025-06-04 16:24:23
+ */
+@Service
+public class SwWaterPriceManagementServiceImpl extends ServiceImpl<SwWaterPriceManagementDao, SwWaterPriceManagementDo>
+        implements SwWaterPriceManagementService {
+
+    @Override
+    public List<SwWaterPriceManagementVo> selectWatertype() {
+       return this.getBaseMapper().selectWatertype();
+    }
+}

+ 69 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/system/domain/SwBookManagementDo.java

@@ -0,0 +1,69 @@
+package com.rongwe.zhsw.system.domain;
+
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 册号管理(SwBookManagement)表实体类
+ *
+ * @author makejava
+ * @since 2025-06-04 16:24:20
+ */
+
+@TableName(value ="sw_book_management")
+@Data
+public class SwBookManagementDo implements Serializable {
+//主键
+    private String id;
+//父级ID
+    private String pid;
+//父级全路径
+    private String fullpid;
+//树表结构编号
+    private String treecode;
+//等级
+    private Integer level;
+//排序
+    private Integer sort;
+//租户ID
+    private String tenantid;
+//扩展json格式配置
+    private String roption;
+//是否删除Y/N
+    private String deleted;
+//备注
+    private String remark;
+//创建时间
+    private Date createdate;
+//创建用户ID
+    private String createuserid;
+//修改日期
+    private Date modifydate;
+//修改用户ID
+    private String modifyuserid;
+//创建人
+    private String createusername;
+//修改人
+    private String modifyusername;
+//册号(编号)
+    private String booknumber;
+//小区/村落/街道名称
+    private String villagename;
+//状态
+    private String status;
+//所属片区
+    private String belongtoarea;
+//抄表负责人ID
+    private String meterreadingmanagerid;
+//抄表负责人名称
+    private String meterreadingmanagername;
+//是否允许新增小区(0 否  1 是)
+    private String isallowaddcommunity;
+
+
+}
+

+ 58 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/system/domain/SwPreferentialUserCategoriesDo.java

@@ -0,0 +1,58 @@
+package com.rongwe.zhsw.system.domain;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 优惠用户类别(SwPreferentialUserCategories)表实体类
+ *
+ * @author makejava
+ * @since 2025-06-04 16:27:10
+ */
+
+@TableName(value ="sw_preferential_user_categories")
+@Data
+public class SwPreferentialUserCategoriesDo implements Serializable {
+//主键
+    private String id;
+//租户ID
+    private String tenantid;
+//扩展json格式配置
+    private String roption;
+//是否删除Y/N
+    private String deleted;
+//备注
+    private String remark;
+//创建时间
+    private Date createdate;
+//创建用户ID
+    private String createuserid;
+//修改日期
+    private Date modifydate;
+//修改用户ID
+    private String modifyuserid;
+//创建人
+    private String createusername;
+//修改人
+    private String modifyusername;
+//优惠类型
+    private String discounttype;
+//每月优惠水(吨)
+    private BigDecimal discountwater;
+//政策说明
+    private String policydescription;
+//用水单价(元/吨)
+    private BigDecimal waterunitprice;
+//每月用水优惠(元)
+
+    private BigDecimal monthlywaterdiscount;
+
+
+
+}
+

+ 14 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/system/domain/SwUserManagementDo.java

@@ -1,5 +1,6 @@
 package com.rongwe.zhsw.system.domain;
 
+import com.alibaba.excel.annotation.ExcelProperty;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -144,4 +145,17 @@ public class SwUserManagementDo extends BaseDo  implements Serializable {
      * 生产厂家
      */
     private String manufacturer;
+    /**
+     * 楼栋
+     */
+    private String bldg;
+    /**
+     * 单元
+     */
+    private String unitnum;
+    /**
+     * 门牌号
+     */
+    private String houseno;
+
 }

+ 66 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/system/domain/SwWaterPriceManagementDo.java

@@ -0,0 +1,66 @@
+package com.rongwe.zhsw.system.domain;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 水价管理(SwWaterPriceManagement)表实体类
+ *
+ * @author makejava
+ * @since 2025-06-04 16:24:22
+ */
+
+@TableName(value ="sw_water_price_management")
+@Data
+public class SwWaterPriceManagementDo implements Serializable {
+//主键
+    private String id;
+//父级ID
+    private String pid;
+//父级全路径
+    private String fullpid;
+//树表结构编号
+    private String treecode;
+//等级
+    private Integer level;
+//排序
+    private Integer sort;
+//租户ID
+    private String tenantid;
+//扩展json格式配置
+    private String roption;
+//是否删除Y/N
+    private String deleted;
+//备注
+    private String remark;
+//创建时间
+    private Date createdate;
+//创建用户ID
+    private String createuserid;
+//修改日期
+    private Date modifydate;
+//修改用户ID
+    private String modifyuserid;
+//创建人
+    private String createusername;
+//修改人
+    private String modifyusername;
+//所属水站(失效)
+    private String waterstation;
+//所属水站ID(失效)
+    private String waterstationid;
+//用水类型
+    private String watertype;
+//价格
+    private BigDecimal price;
+//状态
+    private String status;
+
+
+}
+

+ 67 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/system/vo/ImportUserManagementRecordVo.java

@@ -0,0 +1,67 @@
+package com.rongwe.zhsw.system.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+import java.math.BigDecimal;
+
+@Data
+public class ImportUserManagementRecordVo {
+
+    /**
+     * 户号
+     */
+    @ExcelProperty(index = 0)
+    private String usernumber;
+    /**
+     * 户名
+     */
+    @ExcelProperty(index = 1)
+    private String username;
+    /**
+     * 册号
+     */
+    @ExcelProperty(index = 2)
+    private String volumeno;
+    /**
+     * 用户地址
+     */
+    @ExcelProperty(index = 3)
+    private String address;
+    /**
+     * 电话
+     */
+    @ExcelProperty(index = 4)
+    private String phonenumber;
+    /**
+     * 用水类型
+     */
+    @ExcelProperty(index = 5)
+    private String watertypename;
+    /**
+     * 账户余额
+     */
+    @ExcelProperty(index = 6)
+    private BigDecimal accountbalance;
+    /**
+     * 用户类别
+     */
+    @ExcelProperty(index = 7)
+    private String usertypename;
+    /**
+     * 楼栋
+     */
+    @ExcelProperty(index = 8)
+    private String bldg;
+    /**
+     * 单元
+     */
+    @ExcelProperty(index = 9)
+    private String unitnum;
+    /**
+     * 门牌号
+     */
+    @ExcelProperty(index = 10)
+    private String houseno;
+
+
+}

+ 13 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/system/vo/SwPreferentialUserCategoriesVo.java

@@ -0,0 +1,13 @@
+package com.rongwe.zhsw.system.vo;
+
+import com.rongwe.zhsw.system.domain.SwPreferentialUserCategoriesDo;
+import lombok.Data;
+
+@Data
+public class SwPreferentialUserCategoriesVo extends SwPreferentialUserCategoriesDo {
+
+    /**
+     * 优惠类型名称
+     */
+    private String discounttypename;
+}

+ 13 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/system/vo/SwWaterPriceManagementVo.java

@@ -0,0 +1,13 @@
+package com.rongwe.zhsw.system.vo;
+
+import com.rongwe.zhsw.system.domain.SwWaterPriceManagementDo;
+import lombok.Data;
+
+@Data
+public class SwWaterPriceManagementVo extends SwWaterPriceManagementDo {
+
+    /**
+     * 用水类型名称
+     */
+    private String watertypename;
+}

+ 7 - 0
zhsw-server/src/main/java/com/rongwei/zhsw/system/controller/ImportExcelController.java

@@ -30,4 +30,11 @@ public class ImportExcelController {
     private R meterReadingRecord(@PathVariable("fileId") String fileId) {
         return importExcelService.meterReadingRecord(fileId);
     }
+
+
+
+    @PostMapping("/user-management/{fileId}")
+    private R userManagement(@PathVariable("fileId") String fileId) {
+        return importExcelService.userManagement(fileId);
+    }
 }