Procházet zdrojové kódy

增加开户界面,水表界面排序
开户保存信息按操作员存入redis缓存

wangli před 4 roky
rodič
revize
4e6f8bd537

+ 6 - 2
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayBaseAccountController.java

@@ -46,10 +46,12 @@ public class PayBaseAccountController {
     public AjaxMessage<Pagination<PayBaseAccountSelectDto>> findList(
             @ApiParam(value = "客户编号、证件号码、手机号、地址", required = false) @RequestParam(required = false) String  queryInfo,
             @ApiParam(value = "状态(数据字典中的value)", required = false) @RequestParam(required = false) String  state,
+            @ApiParam(value = "排序参数,对应列表字段", required = false) @RequestParam(required = false) String sortColumn,
+            @ApiParam(value = "排序方式,顺序:ASC  倒序:DESC", required = false) @RequestParam(required = false) String sortOrder,
             @ApiParam(value = "页数,非必传,默认第一页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") Integer pageNum,
             @ApiParam(value = "条数,非必传,默认15条", required = false, defaultValue = "15") @RequestParam(required = false, defaultValue = "15") Integer pageSize)
     {
-        Pagination<PayBaseAccountSelectDto> payBaseAccountSelectDtoPagination = payBaseAccountService.findList(queryInfo,state,pageNum,pageSize);
+        Pagination<PayBaseAccountSelectDto> payBaseAccountSelectDtoPagination = payBaseAccountService.findList(queryInfo,state,sortColumn,sortOrder, pageNum,pageSize);
         return new AjaxMessage<>(ResultStatus.OK,payBaseAccountSelectDtoPagination);
     }
 
@@ -58,11 +60,13 @@ public class PayBaseAccountController {
     public AjaxMessage<Pagination<PayMeter>>findMeter(
             @ApiParam(value = "水表档案号、客户编号、安装地址",required = false) @RequestParam(required = false) String queryInfo,
             @ApiParam(value = "状态(0待验收,1待开户,2已开户)",required = false) @RequestParam(required = false) String state,
+            @ApiParam(value = "排序参数,对应列表字段", required = false) @RequestParam(required = false) String sortColumn,
+            @ApiParam(value = "排序方式,顺序:ASC  倒序:DESC", required = false) @RequestParam(required = false) String sortOrder,
             @ApiParam(value = "页数,非必传,默认第一页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") Integer pageNum,
             @ApiParam(value = "条数,非必传,默认15条", required = false, defaultValue = "15") @RequestParam(required = false, defaultValue = "15") Integer pageSize
     )
     {
-        Pagination<PayMeter> meterInfoPagination = payBaseAccountService.findMeter(queryInfo,state,pageNum,pageSize);
+        Pagination<PayMeter> meterInfoPagination = payBaseAccountService.findMeter(queryInfo,state, sortColumn,sortOrder,pageNum,pageSize);
         return  new AjaxMessage<>(ResultStatus.OK,meterInfoPagination);
     }
 

+ 26 - 5
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/archives/PayBaseCustomerandmeterrelaController.java

@@ -1,15 +1,16 @@
 package com.bz.smart_city.controller.pay.archives;
 
+import com.alibaba.fastjson.JSONObject;
 import com.bz.smart_city.commom.model.AjaxMessage;
 import com.bz.smart_city.commom.model.Pagination;
 import com.bz.smart_city.commom.model.ResultStatus;
+import com.bz.smart_city.commom.util.RedisUtil;
 import com.bz.smart_city.commom.util.UserUtil;
-import com.bz.smart_city.dto.DeviceDto;
 import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.pay.PayCustomerDto;
 import com.bz.smart_city.dto.pay.PaySaveCustomerDto;
-import com.bz.smart_city.entity.pay.PayPayRechargeaccount;
-import com.bz.smart_city.entity.pay.archives.*;
+import com.bz.smart_city.entity.pay.archives.CustomerListInfo;
+import com.bz.smart_city.entity.pay.archives.PayAccountInfo;
 import com.bz.smart_city.service.impl.ImportServiceImpl;
 import com.bz.smart_city.service.pay.archives.PayBaseCustomerandmeterrelaService;
 import io.swagger.annotations.Api;
@@ -24,9 +25,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.math.BigDecimal;
 import java.math.BigInteger;
-import java.util.List;
 
 /**
  * @Author: xjh
@@ -44,6 +43,8 @@ public class PayBaseCustomerandmeterrelaController {
     @Autowired
     private ImportServiceImpl importServiceImpl;
 
+    @Autowired
+    private RedisUtil redisUtil;
 
     @ResponseBody
     @GetMapping("/pageOpenList")
@@ -109,12 +110,32 @@ public class PayBaseCustomerandmeterrelaController {
             paySaveCustomerDto.getFixedamount()); */
         int result = payBaseCustomerandmeterrelaService.saveCustomer(paySaveCustomerDto);
         if(result >0 ){
+            //开户成功后缓存开户信息,下次开户获取其中下拉项
+            redisUtil.set("SaveCustomerCache"+UserUtil.getCurrentUser().getId(), JSONObject.toJSONString(paySaveCustomerDto));
+
             return new AjaxMessage<>(ResultStatus.OK, result);
         }else{
             return new AjaxMessage<>(ResultStatus.ERROR);
         }
     }
 
+    @PostMapping("/getCustomerCache")
+    @ApiOperation(value = "计费系统-获取开户缓存")
+    public AjaxMessage<PaySaveCustomerDto> getCustomerCache(){
+        PaySaveCustomerDto CustomerCache= new PaySaveCustomerDto();
+        if(redisUtil.exists("SaveCustomerCache"+UserUtil.getCurrentUser().getId())){
+
+            String redisString = redisUtil.get("SaveCustomerCache"+UserUtil.getCurrentUser().getId());
+            CustomerCache =JSONObject.parseObject(redisString,PaySaveCustomerDto.class);
+        }else{
+            CustomerCache.setCalculateway(1);
+            CustomerCache.setHousetype(1);
+            CustomerCache.setCustomergroup(1);
+        }
+        return new AjaxMessage<>(ResultStatus.OK, CustomerCache);
+    }
+
+
     @PostMapping("/edit")
     @ApiOperation(value = "计费系统-编辑开户信息")
     public AjaxMessage update(@ApiParam(value = "编辑开户信息",required = true) @RequestBody(required = true) @Validated PaySaveCustomerDto paySaveCustomerDto){

+ 2 - 2
smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayBaseAccountMapper.java

@@ -36,7 +36,7 @@ public interface PayBaseAccountMapper {
     //根据安装计划ID,获取关联的客户ID、预存帐户ID
     List<BigInteger> findPlanAccount(@Param("planId") BigInteger planId,@Param("siteId") BigInteger siteId, @Param("customerId") BigInteger customerId);
 
-    List<PayBaseAccountSelectDto>findList(@Param("queryInfo") String queryInfo,@Param("state") String state, @Param("siteId") BigInteger siteId, @Param("customerId") BigInteger customerId,@Param("year") Integer year,@Param("month") Integer month,@Param("programItemList") List<ProgramItem> programItemList);
+    List<PayBaseAccountSelectDto>findList(@Param("queryInfo") String queryInfo,@Param("state") String state, @Param("sortColumn") String sortColumn,@Param("sortOrder") String sortOrder, @Param("siteId") Integer siteId, @Param("customerId") Integer customerId,@Param("year") Integer year,@Param("month") Integer month,@Param("programItemList") List<ProgramItem> programItemList);
 
     List<PayBaseAccountSelectAccountnumberDto>findAccountnumberList(@Param("queryInfo") String queryInfo,@Param("payment") BigDecimal payment, @Param("siteId") BigInteger siteId, @Param("customerId") BigInteger customerId);
 
@@ -50,7 +50,7 @@ public interface PayBaseAccountMapper {
     List<PayBaseAccountMeterDto> findWaterMeter(@Param("accountnumber") String accountnumber,@Param("siteId") BigInteger siteId, @Param("customerId") BigInteger customerId);
 
     //查询水表信息  涉及到查询云平台数据的如sc_device/抄表数据的,只按customer_id过滤
-    List<PayMeter>findMeterInfo(@Param("queryInfo") String queryInfo, @Param("state") String state, @Param("siteId") BigInteger siteId, @Param("customerId") BigInteger customerId,@Param("year") Integer year,@Param("month") Integer month,@Param("programItemList") List<ProgramItem> programItemList);
+    List<PayMeter>findMeterInfo(@Param("queryInfo") String queryInfo, @Param("state") String state,  @Param("sortColumn") String sortColumn,@Param("sortOrder") String sortOrder, @Param("siteId") BigInteger siteId, @Param("customerId") BigInteger customerId,@Param("year") Integer year,@Param("month") Integer month,@Param("programItemList") List<ProgramItem> programItemList);
 
     void updateAccountName(@Param("type")Integer type,@Param("accountname")String accountname,@Param("accountId")BigInteger accountId);
 }

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayMeter.java

@@ -25,7 +25,7 @@ public class PayMeter {
     @ApiModelProperty(example = "0000000001",value = "客户编号")
     private String accountnumber;
     @ApiModelProperty(example = "深圳宝安",value = "地址")
-    private String installAddress;
+    private String address;
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(example = "2020-04-18 00:00:00",notes = "安装时间")
     private LocalDateTime installDate;

+ 6 - 6
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayBaseAccountServiceImpl.java

@@ -144,7 +144,7 @@ public class PayBaseAccountServiceImpl implements PayBaseAccountService {
     }
 
     @Override
-    public Pagination<PayBaseAccountSelectDto> findList(String queryInfo,String state, Integer pageNum, Integer pageSize)
+    public Pagination<PayBaseAccountSelectDto> findList(String queryInfo,String state,String sortColumn,String sortOrder, Integer pageNum, Integer pageSize)
     {
         LoginUser loginUser = UserUtil.getCurrentUser();
 
@@ -162,9 +162,9 @@ public class PayBaseAccountServiceImpl implements PayBaseAccountService {
         List<ProgramItem> programItemList = loginUser.getDataPermissionMap().get(loginUser.getSiteId());
 
         PageHelper.startPage(pageNum,pageSize);
-        List<PayBaseAccountSelectDto> payBaseAccountSelectDtoList= payBaseAccountMapper.findList(queryInfo,state,
-                new BigInteger(String.valueOf(loginUser.getSiteId())),
-                new BigInteger(String.valueOf(loginUser.getCustomerId())),
+        List<PayBaseAccountSelectDto> payBaseAccountSelectDtoList= payBaseAccountMapper.findList(queryInfo,state,sortColumn,sortOrder,
+               loginUser.getSiteId(),
+                loginUser.getCustomerId(),
                 year,month,programItemList);
         return  new Pagination<>(payBaseAccountSelectDtoList);
     }
@@ -274,7 +274,7 @@ public class PayBaseAccountServiceImpl implements PayBaseAccountService {
     }
 
     @Override
-    public Pagination<PayMeter>findMeter(String queryInfo, String state, Integer pageNum, Integer pageSize)
+    public Pagination<PayMeter>findMeter(String queryInfo, String state,String sortColumn, String sortOrder, Integer pageNum, Integer pageSize)
     {
         LoginUser loginUser = UserUtil.getCurrentUser();
         BigInteger siteId = new BigInteger(String.valueOf(loginUser.getSiteId()));
@@ -295,7 +295,7 @@ public class PayBaseAccountServiceImpl implements PayBaseAccountService {
         List<ProgramItem> programItemList = loginUser.getDataPermissionMap().get(loginUser.getSiteId());
 
         PageHelper.startPage(pageNum,pageSize);
-        List<PayMeter> meterInfoList = payBaseAccountMapper.findMeterInfo(queryInfo,state,siteId,customerId,year,month,programItemList);
+        List<PayMeter> meterInfoList = payBaseAccountMapper.findMeterInfo(queryInfo,state,sortColumn,sortOrder,siteId,customerId,year,month,programItemList);
 
         return new Pagination<>(meterInfoList);
     }

+ 2 - 2
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayBaseAccountService.java

@@ -24,7 +24,7 @@ public interface PayBaseAccountService {
 
     int batchInsert(List<PayBaseAccountDto> list,String code);
 
-    Pagination<PayBaseAccountSelectDto> findList(String queryInfo,String state, Integer pageNum, Integer pageSize);
+    Pagination<PayBaseAccountSelectDto> findList(String queryInfo,String state, String sortColumn,String sortOrder, Integer pageNum, Integer pageSize);
 
     PayBaseAccountSelectAccountnumberDto findAccountnumberList(String accountnumber, Integer Year);
 
@@ -34,7 +34,7 @@ public interface PayBaseAccountService {
 
     List<PaySysDictSelectDto> findState();
 
-    Pagination<PayMeter>findMeter(String queryInfo, String state, Integer pageNum, Integer pageSize);
+    Pagination<PayMeter>findMeter(String queryInfo, String state,String sortColumn, String sortOrder,  Integer pageNum, Integer pageSize);
 
     //根据安装计划ID删除用户信息
     int delByPlanId(BigInteger planId);

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/archives/impl/PayBaseCustomerandmeterrelaServiceImpl.java

@@ -734,7 +734,7 @@ public class PayBaseCustomerandmeterrelaServiceImpl implements PayBaseCustomeran
             //1.查抄未开户水表信息集合
             List<ProgramItem> programItemList = loginUser.getDataPermissionMap().get(siteId);
             //查找待开户信息
-            List<PayMeter> meterInfoList = payBaseAccountMapper.findMeterInfo(null,"1",siteId,customerId,null,null,programItemList);
+            List<PayMeter> meterInfoList = payBaseAccountMapper.findMeterInfo(null,"1",null,null,siteId,customerId,null,null,programItemList);
             //2.查找用水性质集合
             List<BaseWaterPropertyDto> propertyList = baseWaterPropertyMapper.getList(null,customerId,siteId);
             //3.查找结算方式集合

+ 90 - 3
smart-city-platform/src/main/resources/mapper/pay/PayBaseAccountMapper.xml

@@ -268,7 +268,80 @@
     </select>-->
 
     <select id="findList" resultType="com.bz.smart_city.dto.pay.PayBaseAccountSelectDto">
+
+        select
+        IFNULL(cust.waterNumber,0) AS waterNumber,
+        IFNULL(paw.sum_payamount,0) sumPayamount,
+        pba.state as state,
+        (select label from pay_sys_dict where value = pba.state and type='客户状态' and site_id = #{siteId} and customer_id = #{customerId}) stateName,
+
+        IFNULL(dt.remaining,0),
+        (select label from pay_sys_dict where value = pba.idtype and type='证件类型' and site_id = #{siteId} and customer_id = #{customerId}) idTypeName,
+        pba.accountnumber,
+        pba.name,
+        pba.telephone,
+        pba.idcardno,
+        pba.address
+        from pay_base_account pba
+        left join (
             select
+            account_id,
+            sum(payamount) sum_payamount
+            from pay_amount_waterusedamount
+            where  site_id = #{siteId} and customer_id = #{customerId}  and year=#{year} and month=#{month}
+            group by account_id
+        ) paw on paw.account_id = pba.id
+        left join (
+            select
+            rece.account_id
+            ,max(rech.remaining) - sum(rece.debt)  remaining
+            from pay_pay_rechargeaccount rech
+            left join pay_pay_receivable rece on rece.account_id=rech.account_id
+            where rech.site_id = #{siteId} and rech.customer_id = #{customerId}  and rece.debt>0
+            group by rece.account_id
+        ) dt on pba.id = dt.account_id
+        left join (
+            select account_id, count(1) waterNumber,max(office_id) office_id from pay_base_customerandmeterrela
+            where site_id = #{siteId} and customer_id = #{customerId}
+            <if test="programItemList != null and programItemList.size() > 0">
+                and
+                <foreach collection="programItemList" item="item" open="(" separator=" or " close=")">
+                    <if test="item.dimensionId == 10">
+                        ${item.dimensionCode} = #{item.dimensionValue}
+                    </if>
+                </foreach>
+            </if>
+            group by account_id
+        ) cust on pba.id=cust.account_id
+        where pba.del_flag='0'  and pba.site_id=#{siteId} and pba.customer_id=#{customerId}
+        <if test="state != null and state != '' "> and pba.state=#{state}</if>
+        <if test="queryInfo != null and queryInfo != ''">
+            and (pba.accountnumber like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
+            or pba.idcardno like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
+            or pba.telephone like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
+            or pba.address like concat('%',#{queryInfo,jdbcType=VARCHAR} ,'%')
+            )
+        </if>
+        <if test="programItemList != null and programItemList.size() > 0">
+            and
+            ( cust.office_id is null
+            <foreach collection="programItemList" item="item" open="or" separator=" or " close=")">
+                <if test="item.dimensionId == 10">
+                    cust.${item.dimensionCode} = #{item.dimensionValue}
+                </if>
+            </foreach>
+        </if>
+        <choose>
+            <when test="sortColumn !=null and sortColumn != '' and sortOrder !=null and sortOrder != ''">
+                ORDER BY ${sortColumn} ${sortOrder}
+            </when>
+            <otherwise>
+                order by pba.create_date desc,pba.accountnumber DESC
+            </otherwise>
+        </choose>
+
+
+          <!--  select
                  cust.waterNumber AS waterNumber,
                 IFNULL(
                 (select sum(payamount) from pay_amount_waterusedamount paw
@@ -323,7 +396,7 @@
                 </foreach>
             </if>
             order by pba.create_date desc,pba.accountnumber DESC
-
+-->
     </select>
 
 
@@ -471,7 +544,7 @@
         select
             scd.water_meter_no as waterMeterNo,
             scd.metercode,
-            pba.address as installAddress,
+            pba.address as address,
             scinstall.new_meter_start as initialData,
             scinstall.is_accepted ,
             scinstall.install_time as installDate,
@@ -513,7 +586,21 @@
             </if>
         </foreach>
         </if>
-        order by scinstall.install_time DESC
+
+        <choose>
+            <when test="sortColumn !=null and sortColumn != '' and sortOrder !=null and sortOrder != ''">
+                <if test="sortColumn = 'address'">
+                    ORDER BY  pba.address
+                 </if>
+                <if test="sortColumn != 'address'">
+                    ORDER BY ${sortColumn} ${sortOrder}
+                </if>
+            </when>
+            <otherwise>
+                order by scinstall.install_time DESC
+            </otherwise>
+        </choose>
+
 
     </select>