Browse Source

1修改批量导入

Xiaojh 4 years ago
parent
commit
0aa79c276b

+ 12 - 10
smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/archives/PayBaseCustomerandmeterrelaMapper.java

@@ -39,16 +39,16 @@ public interface PayBaseCustomerandmeterrelaMapper {
     public PayPayRechargeaccount findByAccount(@Param("accountId")BigInteger accountId);
 
     public int updateCustomerState(@Param("state")Integer state, @Param("updateBy")Integer updateBy, @Param("date")Date date,
-                                    @Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("id")BigInteger id);
+                                   @Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("id")BigInteger id);
 
     public int updateRechargeAccountState(@Param("state")Integer state, @Param("updateBy")Integer updateBy, @Param("date")Date date,
-                                    @Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("id")BigInteger id);
+                                          @Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("id")BigInteger id);
 
     public int updateAccountState(@Param("state")Integer state, @Param("updateBy")Integer updateBy, @Param("date")Date date,
-                                    @Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("id")BigInteger id);
+                                  @Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("id")BigInteger id);
 
     public int updateDeviceState(@Param("state")Integer state, @Param("updateBy")Integer updateBy, @Param("date")Date date,
-                                  @Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("metercode") String metercode);
+                                 @Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("metercode") String metercode);
 
     public List<PayBaseCustomerandmeterrela> getList (@Param("condition")String condition,@Param("waterPropertyId")BigInteger waterPropertyId,
                                                       @Param("businessstate")Integer businessstate,@Param("calculateway")Integer calculateway,@Param("siteId") Integer siteId, @Param("customerId")Integer customerId);
@@ -63,14 +63,14 @@ public interface PayBaseCustomerandmeterrelaMapper {
     public List<PayAccountInfo> selectAccountMeterInfo (@Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("metercode")String metercode);
 
     public int updateAccountInfo(@Param("accountname")String accountname,@Param("accountnumber")String accountnumber,@Param("metercode")String metercode,@Param("idtype")Integer idtype,
-                              @Param("idcardno")String idcardno,@Param("telephone")String telephone,@Param("officeId")BigInteger officeId,
-                              @Param("housetype")Integer housetype,@Param("customergroup")Integer customergroup,@Param("updateBy")Integer updateBy,
-                              @Param("date")Date date,@Param("siteId") Integer siteId, @Param("customerId")Integer customerId);
+                                 @Param("idcardno")String idcardno,@Param("telephone")String telephone,@Param("officeId")BigInteger officeId,
+                                 @Param("housetype")Integer housetype,@Param("customergroup")Integer customergroup,@Param("updateBy")Integer updateBy,
+                                 @Param("date")Date date,@Param("siteId") Integer siteId, @Param("customerId")Integer customerId);
 
     public int updateCustomerInfo(@Param("accountname")String accountname,@Param("accountnumber")String accountnumber,@Param("metercode")String metercode,@Param("idtype")Integer idtype,
-                              @Param("idcardno")String idcardno,@Param("telephone")String telephone,@Param("officeId")BigInteger officeId,
-                              @Param("housetype")Integer housetype,@Param("customergroup")Integer customergroup,@Param("updateBy")Integer updateBy,
-                              @Param("date")Date date,@Param("siteId") Integer siteId, @Param("customerId")Integer customerId);
+                                  @Param("idcardno")String idcardno,@Param("telephone")String telephone,@Param("officeId")BigInteger officeId,
+                                  @Param("housetype")Integer housetype,@Param("customergroup")Integer customergroup,@Param("updateBy")Integer updateBy,
+                                  @Param("date")Date date,@Param("siteId") Integer siteId, @Param("customerId")Integer customerId);
 
     public List<PayCustomerDto> getAll (PayBaseCustomerandmeterrela payBaseCustomerandmeterrela);
 
@@ -95,4 +95,6 @@ public interface PayBaseCustomerandmeterrelaMapper {
                                                        @Param("accountnumber")String accountnumber,@Param("metercode")String metercode);
 
     public Integer queryMeterState( @Param("customerId")Integer customerId,@Param("accountId")BigInteger accountId);
+
+    public Organization getParentOfficeId( @Param("siteId")Integer siteId,@Param("id")Integer id,@Param("name") String name);
 }

+ 90 - 47
smart-city-platform/src/main/java/com/bz/smart_city/service/importfile/AsyncTaskImportService.java

@@ -285,12 +285,12 @@ public class AsyncTaskImportService {
                                     c_remark.setCellValue(ResultStatus.DELETE_AND_DOOR_EXISTED.getMessage());
                                 }
                             } catch (ServiceException e){
-                                    if(e.getStatus() == ResultStatus.DEVICE_NO_IS_EXISTED.getStatus()){
-                                        failTime++ ;
-                                        c_remark.setCellValue(e.getMessage());
-                                    }else {
-                                        failTime++ ;
-                                    }
+                                if(e.getStatus() == ResultStatus.DEVICE_NO_IS_EXISTED.getStatus()){
+                                    failTime++ ;
+                                    c_remark.setCellValue(e.getMessage());
+                                }else {
+                                    failTime++ ;
+                                }
                             }catch (Exception e){
                                 failTime++ ;
                                 c_remark.setCellValue("导入异常");
@@ -964,8 +964,14 @@ public class AsyncTaskImportService {
                             //根据用水性质名称寻找用水性质id
                             PayBaseCustomerandmeterrela property = payBaseCustomerandmeterrelaMapper.getWaterPropertyId(loginUser.getSiteId(),loginUser.getCustomerId(),propertyName);
                             //根据机构名称寻找机构id
-                            Organization office = payBaseCustomerandmeterrelaMapper.getOfficeId(loginUser.getSiteId(),officeName);
-
+                            Organization office =  null;
+                            if(StringUtils.isNotBlank(officeName)){
+                                String[] number = officeName.split("/");
+                                office = payBaseCustomerandmeterrelaMapper.getOfficeId(loginUser.getSiteId(), number[0]);
+                                for (int i=1; i<number.length; i++){
+                                    office = payBaseCustomerandmeterrelaMapper.getParentOfficeId(loginUser.getSiteId(),office.getId(),number[i]);
+                                }
+                            }
 
                             if(property == null){
                                 failTime++ ;
@@ -1009,51 +1015,88 @@ public class AsyncTaskImportService {
                                 //c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,该客户未验收,");
                                 continue;
                             }
+                            Integer value = 0;
+                            //判断客户是否销户后在开户
+                            PayBaseCustomerandmeterrela baseCustomer = payBaseCustomerandmeterrelaMapper.queryCancelInfo(loginUser.getSiteId(),loginUser.getCustomerId(),accountnumber,metercode);
+                            if(baseCustomer != null && baseCustomer.getBusinessstate() != 1){
+                                //修改开户信息开户状态为已开户
+                                customer.setId(baseCustomer.getId());
+                                customer.setAccountId(accounts.getId());
+                                customer.setAccountnumber(accountnumber);
+                                customer.setAccountname(accountname);
+                                customer.setBusinessstate(1);//1已开户 2 销户 3未开户
+                                value = paySysDictService.getDictValue("结算方式",calculateway,new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                customer.setCalculateway(value);//结算方式
+                                if(value != null && value == 2){
+                                    if(StringUtils.isBlank(fixedamount)){
+                                        failTime++ ;
+                                        msg += "【"+accountnumber+"】添加开户失败,结算水量不能为空,";
+                                        log.info("【"+accountnumber+"】添加开户失败,结算水量不能为空,");
+                                        //c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,该客户已存在,");
+                                        continue;
+                                    }
+                                    customer.setFixedamount(BigDecimal.valueOf(Double.valueOf(fixedamount)));//固定量
+                                }
+                                customer.setWatermeterId(device.getId());
+                                customer.setMetercode(metercode);
+                                customer.setOfficeId(BigInteger.valueOf(office.getId()));
+                                customer.setUpdateBy(loginUser.getId());
+                                customer.setUpdateDate(LocalDateTime.now());
+                                value = paySysDictService.getDictValue("住房类型",housetypeCell.getStringCellValue(),new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                customer.setHousetype(value);//住房类型
+                                value = paySysDictService.getDictValue("开户分组",customergroupCell.getStringCellValue(),new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                customer.setCustomergroup(value);//开户分组
+
+                                customer.setOpendate(LocalDateTime.now());
+                                customer.setWaterPropertyId(property.getWaterPropertyId());
+                                payBaseCustomerandmeterrelaMapper.update(customer);
+                            }else{
+                                //判断该客户编码跟水表档案是否已经存在开户信息中
+                                Integer count = payBaseCustomerandmeterrelaMapper.queryCustomerInfo(loginUser.getSiteId(),loginUser.getCustomerId(),accountnumber,metercode);
+                                if(count != null && count >0){
 
-                            //判断该客户编码跟水表档案是否已经存在开户信息中
-                            Integer count = payBaseCustomerandmeterrelaMapper.queryCustomerInfo(loginUser.getSiteId(),loginUser.getCustomerId(),accountnumber,metercode);
-                            if(count != null && count >0){
-                                failTime++ ;
-                                msg += "【"+accountnumber+"】添加开户失败,该客户已存在,";
-                                log.info("【"+accountnumber+"】添加开户失败,该客户已存在,");
-                                //c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,该客户已存在,");
-                                continue;
-                            }
-
-                            customer.setAccountId(accounts.getId());
-                            customer.setAccountname(accountname);
-                            customer.setAccountnumber(accountnumber);
-                            customer.setBusinessstate(1);//1已开户 2 销户 3未开户
-                            Integer value = paySysDictService.getDictValue("结算方式",calculateway,new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
-                            customer.setCalculateway(value);//结算方式
-                            if(value != null && value == 2){
-                                if(StringUtils.isBlank(fixedamount)){
                                     failTime++ ;
-                                    msg += "【"+accountnumber+"】添加开户失败,结算水量不能为空,";
-                                    log.info("【"+accountnumber+"】添加开户失败,结算水量不能为空,");
+                                    msg += "【"+accountnumber+"】添加开户失败,该客户已存在,";
+                                    log.info("【"+accountnumber+"】添加开户失败,该客户已存在,");
                                     //c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,该客户已存在,");
                                     continue;
                                 }
-                                customer.setFixedamount(BigDecimal.valueOf(Double.valueOf(fixedamount)));//固定量
+
+                                customer.setAccountId(accounts.getId());
+                                customer.setAccountname(accountname);
+                                customer.setAccountnumber(accountnumber);
+                                customer.setBusinessstate(1);//1已开户 2 销户 3未开户
+                                value = paySysDictService.getDictValue("结算方式",calculateway,new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                customer.setCalculateway(value);//结算方式
+                                if(value != null && value == 2){
+                                    if(StringUtils.isBlank(fixedamount)){
+                                        failTime++ ;
+                                        msg += "【"+accountnumber+"】添加开户失败,结算水量不能为空,";
+                                        log.info("【"+accountnumber+"】添加开户失败,结算水量不能为空,");
+                                        //c_remark.setCellValue( "【"+accountnumber+"】添加开户失败,该客户已存在,");
+                                        continue;
+                                    }
+                                    customer.setFixedamount(BigDecimal.valueOf(Double.valueOf(fixedamount)));//固定量
+                                }
+                                customer.setWatermeterId(device.getId());
+                                customer.setMetercode(metercode);
+                                customer.setOfficeId(BigInteger.valueOf(office.getId()));
+                                customer.setUpdateBy(loginUser.getId());
+                                customer.setUpdateDate(LocalDateTime.now());
+                                customer.setCreateBy(loginUser.getId());
+                                customer.setCreateDate(LocalDateTime.now());
+                                customer.setDelFlag("0");
+                                customer.setRemarks("");
+                                customer.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
+                                customer.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
+                                value = paySysDictService.getDictValue("住房类型",housetypeCell.getStringCellValue(),new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                customer.setHousetype(value);//住房类型
+                                value = paySysDictService.getDictValue("开户分组",customergroupCell.getStringCellValue(),new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
+                                customer.setCustomergroup(value);//开户分组
+                                customer.setOpendate(LocalDateTime.now());
+                                customer.setWaterPropertyId(property.getWaterPropertyId());
+                                customerList.add(customer);
                             }
-                            customer.setWatermeterId(device.getId());
-                            customer.setMetercode(metercode);
-                            customer.setOfficeId(new BigInteger(String.valueOf(office.getId())));
-                            customer.setUpdateBy(loginUser.getId());
-                            customer.setUpdateDate(LocalDateTime.now());
-                            customer.setCreateBy(loginUser.getId());
-                            customer.setCreateDate(LocalDateTime.now());
-                            customer.setDelFlag("0");
-                            customer.setRemarks("");
-                            customer.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
-                            customer.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
-                            value = paySysDictService.getDictValue("住房类型",housetypeCell.getStringCellValue(),new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
-                            customer.setHousetype(value);//住房类型
-                            value = paySysDictService.getDictValue("开户分组",customergroupCell.getStringCellValue(),new BigInteger(String.valueOf(loginUser.getSiteId())),new BigInteger(String.valueOf(loginUser.getCustomerId())));
-                            customer.setCustomergroup(value);//开户分组
-                            customer.setOpendate(LocalDateTime.now());
-                            customer.setWaterPropertyId(property.getWaterPropertyId());
-                            customerList.add(customer);
 
                             //计算可用水量
                             if(property.getWaterPropertyId() != null){

BIN
smart-city-platform/src/main/resources/excel/batchOpenAccountTemplate.xlsx


+ 164 - 160
smart-city-platform/src/main/resources/mapper/PayBaseCustomerandmeterrelaMapper.xml

@@ -23,19 +23,19 @@
 
     <select id="findList" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
         select
-            customer.id as "id",
-            customer.watermeter_id as "watermeterId",
-            account.id as "accountId",
-            account.accountnumber as "accountnumber",
-            customer.office_id as "officeId",
-            account.name as "name",
-            account.telephone as "telephone",
-            customer.metercode as "metercode",
-            pro.name as "propertyName",
-            account.address as "address",
-            customer.opendate as "opendate",
-            customer.businessstate as "businessstate",
-            customer.calculateway as "calculateway"
+        customer.id as "id",
+        customer.watermeter_id as "watermeterId",
+        account.id as "accountId",
+        account.accountnumber as "accountnumber",
+        customer.office_id as "officeId",
+        account.name as "name",
+        account.telephone as "telephone",
+        customer.metercode as "metercode",
+        pro.name as "propertyName",
+        account.address as "address",
+        customer.opendate as "opendate",
+        customer.businessstate as "businessstate",
+        customer.calculateway as "calculateway"
         from pay_base_customerandmeterrela customer
         left join pay_base_account account on customer.account_id = account.id
         left join pay_base_waterproperty pro on pro.id = customer.waterproperty_id
@@ -58,7 +58,7 @@
 
     <select id="getAccountId" resultType="com.bz.smart_city.entity.pay.PayBaseAccount">
         select
-            id as "id"
+        id as "id"
         from pay_base_account
         <where>
             <if test="siteId != null">
@@ -112,69 +112,69 @@
     <insert id="insertList">
         INSERT INTO pay_base_customerandmeterrela
         (
-            id,
-            account_id,
-            watermeter_id,
-            accountname,
-            accountnumber,
-            metercode,
-            businessstate,
-            office_id,
-            housetype,
-            calculateway,
-            customercategory,
-            customergroup,
-            fixedamount,
-            vatno,
-            bankaccount,
-            invoicetitle,
-            address,
-            opendate,
-            waterproperty_id,
-            watertype,
-            canceldate,
-            create_by,
-            create_date,
-            update_by,
-            update_date,
-            remarks,
-            del_flag,
-            site_id,
-            customer_id
+        id,
+        account_id,
+        watermeter_id,
+        accountname,
+        accountnumber,
+        metercode,
+        businessstate,
+        office_id,
+        housetype,
+        calculateway,
+        customercategory,
+        customergroup,
+        fixedamount,
+        vatno,
+        bankaccount,
+        invoicetitle,
+        address,
+        opendate,
+        waterproperty_id,
+        watertype,
+        canceldate,
+        create_by,
+        create_date,
+        update_by,
+        update_date,
+        remarks,
+        del_flag,
+        site_id,
+        customer_id
         )
         values
         <foreach collection="customers" item="customer" index="index" separator=",">
-        (
-             #{customer.id,jdbcType=BIGINT},
-             #{customer.accountId,jdbcType=BIGINT},
-             #{customer.watermeterId,jdbcType=BIGINT},
-             #{customer.accountname,jdbcType=VARCHAR},
-             #{customer.accountnumber,jdbcType=VARCHAR},
-             #{customer.metercode,jdbcType=VARCHAR},
-             #{customer.businessstate,jdbcType=INTEGER},
-             #{customer.officeId,jdbcType=BIGINT},
-             #{customer.housetype,jdbcType=INTEGER},
-             #{customer.calculateway,jdbcType=INTEGER},
-             #{customer.customercategory,jdbcType=INTEGER},
-             #{customer.customergroup,jdbcType=INTEGER},
-             #{customer.fixedamount,jdbcType=VARCHAR},
-             #{customer.vatno,jdbcType=VARCHAR},
-             #{customer.bankaccount,jdbcType=VARCHAR},
-             #{customer.invoicetitle,jdbcType=VARCHAR},
-             #{customer.address,jdbcType=VARCHAR},
-             #{customer.opendate,jdbcType=TIMESTAMP},
-             #{customer.waterPropertyId,jdbcType=BIGINT},
-             #{customer.watertype,jdbcType=INTEGER},
-             #{customer.canceldate,jdbcType=TIMESTAMP},
-             #{customer.createBy,jdbcType=VARCHAR},
-             #{customer.createDate,jdbcType=TIMESTAMP},
-             #{customer.updateBy,jdbcType=VARCHAR},
-             #{customer.updateDate,jdbcType=TIMESTAMP},
-             #{customer.remarks,jdbcType=VARCHAR},
-             #{customer.delFlag,jdbcType=VARCHAR},
-             #{customer.siteId,jdbcType=BIGINT},
-             #{customer.customerId,jdbcType=BIGINT}
-        )
+            (
+            #{customer.id,jdbcType=BIGINT},
+            #{customer.accountId,jdbcType=BIGINT},
+            #{customer.watermeterId,jdbcType=BIGINT},
+            #{customer.accountname,jdbcType=VARCHAR},
+            #{customer.accountnumber,jdbcType=VARCHAR},
+            #{customer.metercode,jdbcType=VARCHAR},
+            #{customer.businessstate,jdbcType=INTEGER},
+            #{customer.officeId,jdbcType=BIGINT},
+            #{customer.housetype,jdbcType=INTEGER},
+            #{customer.calculateway,jdbcType=INTEGER},
+            #{customer.customercategory,jdbcType=INTEGER},
+            #{customer.customergroup,jdbcType=INTEGER},
+            #{customer.fixedamount,jdbcType=VARCHAR},
+            #{customer.vatno,jdbcType=VARCHAR},
+            #{customer.bankaccount,jdbcType=VARCHAR},
+            #{customer.invoicetitle,jdbcType=VARCHAR},
+            #{customer.address,jdbcType=VARCHAR},
+            #{customer.opendate,jdbcType=TIMESTAMP},
+            #{customer.waterPropertyId,jdbcType=BIGINT},
+            #{customer.watertype,jdbcType=INTEGER},
+            #{customer.canceldate,jdbcType=TIMESTAMP},
+            #{customer.createBy,jdbcType=VARCHAR},
+            #{customer.createDate,jdbcType=TIMESTAMP},
+            #{customer.updateBy,jdbcType=VARCHAR},
+            #{customer.updateDate,jdbcType=TIMESTAMP},
+            #{customer.remarks,jdbcType=VARCHAR},
+            #{customer.delFlag,jdbcType=VARCHAR},
+            #{customer.siteId,jdbcType=BIGINT},
+            #{customer.customerId,jdbcType=BIGINT}
+            )
         </foreach>
     </insert>
 
@@ -214,7 +214,7 @@
 
     <select id="findByAccount" resultType="com.bz.smart_city.entity.pay.PayPayRechargeaccount">
         select
-            rech.*
+        rech.*
         from pay_pay_rechargeaccount rech
         <where>
             <if test="accountId != null">
@@ -237,28 +237,28 @@
 
     <select id="getAll" resultType="com.bz.smart_city.dto.pay.PayCustomerDto">
         select
-            customer.fixedamount as "fixedamount",
-            customer.id as "id",
-            account.accountnumber as "accountnumber",
-            account.name as "accountname",
-            account.telephone as "telephone",
-            customer.metercode as "metercode",
-            property.id as "waterPropertyId",
-            property.name as "waterPropertyName",
-            account.address as "address",
-            customer.opendate as "opendate",
-            customer.office_id as "officeId",
-            customer.businessstate as "businessstate",
-            (select label from pay_sys_dict where type = '开户状态' and value = customer.businessstate and site_id = #{siteId} and customer_id =#{customerId}) as "businessName",
-            customer.calculateway as "calculateway",
-            (select label from pay_sys_dict where type = '结算方式' and value = customer.calculateway and site_id = #{siteId} and customer_id =#{customerId}) as "calculatewayName",
-            account.idtype as "idtype",
-            (select label from pay_sys_dict where type = '证件类型' and value = account.idtype and site_id = #{siteId} and customer_id =#{customerId}) as "idtypeName",
-            account.idcardno as "idcardno",
-            customer.housetype as "housetype",
-            (select label from pay_sys_dict where type = '住房类型' and value = customer.housetype and site_id = #{siteId} and customer_id =#{customerId}) as "housetypeName",
-            customer.customergroup as "customergroup",
-            (select label from pay_sys_dict where type = '开户分组' and value = customer.customergroup and site_id = #{siteId} and customer_id =#{customerId}) as "customergroupName"
+        customer.fixedamount as "fixedamount",
+        customer.id as "id",
+        account.accountnumber as "accountnumber",
+        account.name as "accountname",
+        account.telephone as "telephone",
+        customer.metercode as "metercode",
+        property.id as "waterPropertyId",
+        property.name as "waterPropertyName",
+        account.address as "address",
+        customer.opendate as "opendate",
+        customer.office_id as "officeId",
+        customer.businessstate as "businessstate",
+        (select label from pay_sys_dict where type = '开户状态' and value = customer.businessstate and site_id = #{siteId} and customer_id =#{customerId}) as "businessName",
+        customer.calculateway as "calculateway",
+        (select label from pay_sys_dict where type = '结算方式' and value = customer.calculateway and site_id = #{siteId} and customer_id =#{customerId}) as "calculatewayName",
+        account.idtype as "idtype",
+        (select label from pay_sys_dict where type = '证件类型' and value = account.idtype and site_id = #{siteId} and customer_id =#{customerId}) as "idtypeName",
+        account.idcardno as "idcardno",
+        customer.housetype as "housetype",
+        (select label from pay_sys_dict where type = '住房类型' and value = customer.housetype and site_id = #{siteId} and customer_id =#{customerId}) as "housetypeName",
+        customer.customergroup as "customergroup",
+        (select label from pay_sys_dict where type = '开户分组' and value = customer.customergroup and site_id = #{siteId} and customer_id =#{customerId}) as "customergroupName"
         from pay_base_customerandmeterrela customer
         left join pay_base_account account on account.id = customer.account_id
         left join pay_base_waterproperty property on property.id = customer.waterproperty_id
@@ -272,11 +272,11 @@
             <if test="condition != null">
                 and
                 (
-                    account.accountnumber like concat('%',#{condition},'%')
-                    or account.name like concat('%',#{condition},'%')
-                    or customer.metercode like  concat('%',#{condition},'%')
-                    or account.address  like concat('%',#{condition},'%')
-                    or account.telephone like concat('%',#{condition},'%')
+                account.accountnumber like concat('%',#{condition},'%')
+                or account.name like concat('%',#{condition},'%')
+                or customer.metercode like  concat('%',#{condition},'%')
+                or account.address  like concat('%',#{condition},'%')
+                or account.telephone like concat('%',#{condition},'%')
                 )
             </if>
             <if test="waterPropertyId != null">
@@ -301,15 +301,15 @@
 
     <select id="getList" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
         select
-            account.accountnumber as "accountnumber",
-            account.name as "accountname",
-            account.telephone as "telephone",
-            customer.metercode as "metercode",
-            property.name as "propertyName",
-            device.loc_desc as "address",
-            customer.opendate as "opendate",
-            customer.businessstate as "businessstate",
-            customer.calculateway as "calculateway"
+        account.accountnumber as "accountnumber",
+        account.name as "accountname",
+        account.telephone as "telephone",
+        customer.metercode as "metercode",
+        property.name as "propertyName",
+        device.loc_desc as "address",
+        customer.opendate as "opendate",
+        customer.businessstate as "businessstate",
+        customer.calculateway as "calculateway"
         from pay_base_customerandmeterrela customer
         left join pay_base_account account on account.id = customer.account_id
         left join pay_base_waterproperty property on property.id = customer.waterproperty_id
@@ -324,11 +324,11 @@
             <if test="condition != null">
                 and
                 (
-                    account.accountnumber like concat('%',#{condition},'%')
-                    or account.name like concat('%',#{condition},'%')
-                    or customer.metercode like  concat('%',#{condition},'%')
-                    or account.address  like concat('%',#{condition},'%')
-                    or account.telephone like concat('%',#{condition},'%')
+                account.accountnumber like concat('%',#{condition},'%')
+                or account.name like concat('%',#{condition},'%')
+                or customer.metercode like  concat('%',#{condition},'%')
+                or account.address  like concat('%',#{condition},'%')
+                or account.telephone like concat('%',#{condition},'%')
                 )
             </if>
             <if test="waterPropertyId != null">
@@ -347,7 +347,7 @@
 
     <select id="queryNoOpenAccount" resultType="com.bz.smart_city.entity.pay.archives.DeviceListInfo">
         select
-            account.accountnumber as "accountnumber"
+        account.accountnumber as "accountnumber"
         from pay_base_account account
         <where>
             <if test="siteId != null">
@@ -362,7 +362,7 @@
 
     <select id="selectAccountInfo" resultType="com.bz.smart_city.entity.pay.archives.MeterListInfo">
         select
-            device.metercode as "metercode"
+        device.metercode as "metercode"
         from pay_base_account account
         inner join sc_device device on account.id = device.account_id
         <where>
@@ -370,9 +370,9 @@
             <if test="accountnumber != null">
                 and account.accountnumber =#{accountnumber}
             </if>
-           <!-- <if test="siteId != null">
-                and  account.site_id = #{siteId}
-            </if>-->
+            <!-- <if test="siteId != null">
+                 and  account.site_id = #{siteId}
+             </if>-->
             <if test="customerId != null">
                 and account.customer_id = #{customerId}
             </if>
@@ -382,10 +382,10 @@
 
     <select id="selectAccountMeterInfo" resultType="com.bz.smart_city.entity.pay.archives.PayAccountInfo">
         select
-            account.accountnumber as "accountnumber",
-            account.calculateway as "calculateway",
-            account.waterproperty_id as "waterPropertyId",
-            device.metercode as "metercode"
+        account.accountnumber as "accountnumber",
+        account.calculateway as "calculateway",
+        account.waterproperty_id as "waterPropertyId",
+        device.metercode as "metercode"
         from pay_base_account account
         inner join sc_device device on account.id = device.account_id
         <where>
@@ -405,9 +405,9 @@
 
     <select id="selectAccountWater" resultType="com.bz.smart_city.entity.pay.archives.CustomerListInfo">
         select
-            accountnumber as "accountnumber",
-            calculateway as "calculateway" ,
-            waterproperty_id as "waterPropertyId"
+        accountnumber as "accountnumber",
+        calculateway as "calculateway" ,
+        waterproperty_id as "waterPropertyId"
         from pay_base_account account
         inner join sc_device device on account.id = device.account_id
         <where>
@@ -427,7 +427,7 @@
 
     <select id="queryMetercode" resultType="com.bz.smart_city.entity.pay.archives.MeterListInfo">
         select
-            metercode from sc_device deivce
+        metercode from sc_device deivce
         <where>
             deivce.metercode not in (select metercode from pay_base_customerandmeterrela) and deivce.metercode is not null
             <!--<if test="siteId != null">
@@ -498,7 +498,7 @@
         from pay_base_customerandmeterrela a
 
         <where>
-                a.id =#{id}
+            a.id =#{id}
         </where>
     </select>
 
@@ -544,36 +544,36 @@
     </select>
 
     <select id="queryCancelInfo" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
-         select
-            a.id,
-            a.account_id AS "accountId",
-            a.watermeter_id AS "watermeterId",
-            a.accountname,
-            a.accountnumber,
-            a.metercode,
-            a.businessstate,
-            a.office_id AS "officeId",
-            a.housetype,
-            a.calculateway,
-            a.customercategory,
-            a.customergroup,
-            a.fixedamount,
-            a.vatno,
-            a.bankaccount,
-            a.invoicetitle,
-            a.address,
-            a.opendate,
-            a.waterproperty_id AS "waterpropertyId",
-            a.watertype,
-            a.canceldate,
-            a.create_by AS "createBy",
-            a.create_date AS "createDate",
-            a.update_by AS "updateBy",
-            a.update_date AS "updateDate",
-            a.remarks AS "remarks",
-            a.del_flag AS "delFlag",
-            a.site_id as "siteId",
-            a.customer_id as "customerId"
+        select
+        a.id,
+        a.account_id AS "accountId",
+        a.watermeter_id AS "watermeterId",
+        a.accountname,
+        a.accountnumber,
+        a.metercode,
+        a.businessstate,
+        a.office_id AS "officeId",
+        a.housetype,
+        a.calculateway,
+        a.customercategory,
+        a.customergroup,
+        a.fixedamount,
+        a.vatno,
+        a.bankaccount,
+        a.invoicetitle,
+        a.address,
+        a.opendate,
+        a.waterproperty_id AS "waterpropertyId",
+        a.watertype,
+        a.canceldate,
+        a.create_by AS "createBy",
+        a.create_date AS "createDate",
+        a.update_by AS "updateBy",
+        a.update_date AS "updateDate",
+        a.remarks AS "remarks",
+        a.del_flag AS "delFlag",
+        a.site_id as "siteId",
+        a.customer_id as "customerId"
         from pay_base_customerandmeterrela a
         <where>
             <if test="siteId != null">
@@ -594,4 +594,8 @@
     <select id="queryMeterState" resultType="java.lang.Integer">
         select is_accepted as "isAccepted" from sc_install_list where account_id =#{accountId}  and customer_id =#{customerId}
     </select>
+
+    <select id="getParentOfficeId" resultType="com.bz.smart_city.entity.Organization">
+        select id from sc_organization where site_id =#{siteId} and parent_id =#{id} and name =#{name}
+    </select>
 </mapper>

+ 21 - 20
smart-city-platform/src/main/resources/mapper/pay/PayRechargeaccountMapper.xml

@@ -20,16 +20,17 @@
     </sql>
     <select id="findList" resultType="com.bz.smart_city.dto.pay.PayRechargeaccountDto">
         select
-            <include refid="mainColumnInfo"/>
-            ,cust.accountname as "accountname"
+        <include refid="mainColumnInfo"/>
+        ,cust.accountname as "accountname"
         from pay_pay_rechargeaccount a
         left join pay_base_customerandmeterrela cust on a.account_id=cust.account_id
 
 
         <where>
+            cust.businessstate = 1
             <if test="accountnumber != null and accountnumber != ''">
-              and  (cust.accountnumber like concat('%',#{accountnumber},'%')
-               or  cust.accountname like concat('%',#{accountnumber},'%'))
+                and  (cust.accountnumber like concat('%',#{accountnumber},'%')
+                or  cust.accountname like concat('%',#{accountnumber},'%'))
             </if>
             <if test="siteId != null">
                 and a.site_id=#{siteId}
@@ -41,11 +42,11 @@
                 and a.account_id =#{accountId}
             </if>
             <if test="programItems != null and programItems.size() != 0">
-              and  <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
-                    <if test="item.dimensionId == 10">
-                        cust.${item.dimensionCode} = #{item.dimensionValue}
-                    </if>
-                </foreach>
+                and  <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
+                <if test="item.dimensionId == 10">
+                    cust.${item.dimensionCode} = #{item.dimensionValue}
+                </if>
+            </foreach>
             </if>
         </where>
         order by a.create_date desc
@@ -61,7 +62,7 @@
                 and id=#{id}
             </if>
             <if test="accountId != null">
-              and account_id=#{accountId}
+                and account_id=#{accountId}
             </if>
         </where>
     </select>
@@ -111,36 +112,36 @@
             </if>
 
             <if test="businessstate != null ">
-            businessstate = #{businessstate},
+                businessstate = #{businessstate},
             </if>
 
             <if test="accountnumber != null and accountnumber!='' ">
-            accountnumber = #{accountnumber},
+                accountnumber = #{accountnumber},
             </if>
             <if test="accountname != null and accountname!='' ">
-            accountname = #{accountname},
+                accountname = #{accountname},
             </if>
 
             <if test="remaining != null ">
-            remaining = #{remaining},
+                remaining = #{remaining},
             </if>
 
             <if test="updateDate != null ">
-            update_date = #{updateDate},
+                update_date = #{updateDate},
             </if>
 
             <if test="updateBy != null ">
-            update_by = #{updateBy},
+                update_by = #{updateBy},
             </if>
             <if test="customerId != null">
-            customer_id = #{customerId},
+                customer_id = #{customerId},
             </if>
 
             <if test="siteId != null ">
-            site_id = #{siteId},
+                site_id = #{siteId},
             </if>
             <if test="officeId != null ">
-            office_id = #{officeId}
+                office_id = #{officeId}
             </if>
         </set>
         <where>
@@ -171,7 +172,7 @@
         insert INTO
         pay_pay_rechargeaccount
         (id,
-         account_id,
+        account_id,
         businessstate,
         accountnumber,
         accountname,