From 29ecefa321a8c08b47d21cac682775c81840210e Mon Sep 17 00:00:00 2001 From: yuyang Date: Sun, 24 Apr 2022 14:28:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=BA=E6=9E=84=E4=BA=BA?= =?UTF-8?q?=E5=91=98=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controller/SysUserController.java | 1 + .../mapper/XhpcHistoryOrderMapper.xml | 4 +- .../user/controller/XhpcCommonController.java | 23 +++ .../xhpc/user/mapper/XhpcCommonMapper.java | 4 + .../xhpc/user/service/IXhpcCommonService.java | 11 ++ .../service/impl/XhpcCommonServiceImpl.java | 104 ++++++++++- .../service/impl/XhpcInvoiceServiceImpl.java | 2 +- .../resources/mapper/XhpcCommonMapper.xml | 165 ++++++++++++++++++ .../resources/mapper/XhpcOperatorMapper.xml | 3 +- .../main/resources/mapper/XhpcUserMapper.xml | 28 ++- 10 files changed, 332 insertions(+), 13 deletions(-) diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/controller/SysUserController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/controller/SysUserController.java index 2a29662d..2a0eab74 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/controller/SysUserController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/controller/SysUserController.java @@ -103,6 +103,7 @@ public class SysUserController extends BaseController { String[] split = username.split("&"); SysUser sysUser = userService.selectUserByUserName(split[0],split[1]); + System.out.println(); if (StringUtils.isNull(sysUser)) { return R.fail("用户名或密码错误"); } diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml index fa4ac338..7d93a28f 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -611,7 +611,7 @@ DATE_FORMAT(ho.end_time,'%H:%i:%s') as timeTwo, co.status as status, co.type as type, - ho.StopReasonEvcs as typeName + ho.stop_reason_evcs as typeName FROM xhpc_history_order as ho LEFT JOIN xhpc_charging_station as cs on cs.charging_station_id = ho.charging_station_id LEFT JOIN xhpc_terminal as te on te.terminal_id = ho.terminal_id @@ -879,7 +879,7 @@ (SELECT account from xhpc_customers_personnel where customers_personnel_id = co.user_id and ho.source=3) as customersAccount, co.Plate_num as plateNum, (SELECT name from xhpc_internet_user where internet_user_id = co.user_id and co.source =1) as internetName, - ho.StopReasonEvcs as stopReasonRvcsName + ho.stop_reason_evcs as stopReasonRvcsName from xhpc_history_order ho left join xhpc_charging_station as ct on ct.charging_station_id = ho.charging_station_id left join xhpc_operator as op on op.operator_id = ct.operator_id diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommonController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommonController.java index fd84cf5f..ae87a765 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommonController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommonController.java @@ -3,15 +3,21 @@ package com.xhpc.user.controller; import com.xhpc.common.core.domain.R; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.core.web.page.TableDataInfo; import com.xhpc.common.util.UserTypeUtil; import com.xhpc.user.service.IXhpcCommonService; import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.math.BigDecimal; +import java.util.List; +import java.util.Map; /** * 公共的内 @@ -84,6 +90,23 @@ public class XhpcCommonController extends BaseController { return xhpcCommonService.getMechanismDiscount(userId,userType,tenantId,chargingStationId); } + /** + * 机构人员统计 + */ + @GetMapping(value = "/getPersonnelStatistics") + public TableDataInfo getPersonnelStatistics(Long operatorId, Long chargingStationId, Long chargingPileId, Integer type, String name , String phone, String account) { + List> list = xhpcCommonService.getPersonnelStatistics(operatorId,chargingStationId,chargingPileId,type,name,phone,account); + return getDataTable(list); + } + + /** + * 机构人员统计 + */ + @PostMapping(value = "/getPersonnelStatisticsExport") + public void getPersonnelStatisticsExport(HttpServletResponse response, Long operatorId, Long chargingStationId, Long chargingPileId, Integer type, String name , String phone, String account)throws IOException { + xhpcCommonService.getPersonnelStatisticsExport(response,operatorId,chargingStationId,chargingPileId,type,name,phone,account); + } + diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCommonMapper.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCommonMapper.java index 6f8814aa..014acf3d 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCommonMapper.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCommonMapper.java @@ -2,6 +2,7 @@ package com.xhpc.user.mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; import java.util.Map; /** @@ -25,4 +26,7 @@ public interface XhpcCommonMapper { * B端用户信息 */ Map getCustomersUser(@Param("phone") String phone,@Param("userId")Long userId,@Param("serialNumber")String serialNumber,@Param("tenantId") String tenantId); + + + List> getPersonnelStatistics(@Param("operatorId")Long operatorId,@Param("chargingStationId") Long chargingStationId, @Param("chargingPileId")Long chargingPileId, @Param("type")Integer type, @Param("name")String name , @Param("phone")String phone, @Param("account")String account,@Param("number") Integer number,@Param("userId") Long userId,@Param("tenantId")String tenantId); } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommonService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommonService.java index f833186e..8417e326 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommonService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommonService.java @@ -2,7 +2,10 @@ package com.xhpc.user.service; import com.xhpc.common.core.web.domain.AjaxResult; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.math.BigDecimal; +import java.util.List; import java.util.Map; /** @@ -39,4 +42,12 @@ public interface IXhpcCommonService { */ AjaxResult getMechanismDiscount(Long userId, Integer userType, String tenantId, Long chargingStationId); + + /** + * 根据用户手机号获取用户信息 + */ + List> getPersonnelStatistics(Long operatorId, Long chargingStationId, Long chargingPileId, Integer type, String name , String phone, String account); + + + void getPersonnelStatisticsExport(HttpServletResponse response, Long operatorId, Long chargingStationId, Long chargingPileId, Integer type, String name , String phone, String account)throws IOException; } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommonServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommonServiceImpl.java index 3043388c..b5fe55ff 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommonServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommonServiceImpl.java @@ -1,7 +1,14 @@ package com.xhpc.user.service.impl; +import cn.hutool.core.io.IoUtil; +import cn.hutool.poi.excel.BigExcelWriter; +import cn.hutool.poi.excel.ExcelUtil; import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.core.web.service.BaseService; +import com.xhpc.common.security.service.TokenService; import com.xhpc.common.util.UserTypeUtil; +import com.xhpc.system.api.domain.SysUser; +import com.xhpc.system.api.model.LoginUser; import com.xhpc.user.domain.XhpcCommunityPersonnel; import com.xhpc.user.domain.XhpcCustomersPersonnel; import com.xhpc.user.mapper.XhpcCommonMapper; @@ -12,8 +19,14 @@ import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -21,7 +34,7 @@ import java.util.Map; * @date 2021/12/29 11:11 */ @Service -public class XhpcCommonServiceImpl implements IXhpcCommonService { +public class XhpcCommonServiceImpl extends BaseService implements IXhpcCommonService { @Autowired private XhpcCommonMapper xhpcCommonMapper; @@ -29,7 +42,8 @@ public class XhpcCommonServiceImpl implements IXhpcCommonService { private IXhpcCommunityService xhpcCommunityService; @Autowired private IXhpcCustomersService xhpcCustomersService; - + @Autowired + TokenService tokenService; @Override public Map getLandUser(String phone,Long userId, Integer type,String serialNumber,String tenantId) { @@ -98,4 +112,90 @@ public class XhpcCommonServiceImpl implements IXhpcCommonService { return AjaxResult.error(); } } + + /** + * 根据用户手机号获取用户信息 + * + * @param operatorId + * @param chargingStationId + * @param chargingPileId + * @param type + * @param name + * @param phone + * @param account + */ + @Override + public List> getPersonnelStatistics(Long operatorId, Long chargingStationId, Long chargingPileId, Integer type, String name, String phone, String account) { + + //获取登陆用户 + LoginUser loginUser = tokenService.getLoginUser(); + SysUser sysUser = loginUser.getSysUser(); + String tenantId = loginUser.getTenantId(); + Long sysUserId = sysUser.getUserId(); + //获取登陆用户 + List> list =new ArrayList<>(); + + if(!UserTypeUtil.SYS_USER_TYPE_ADMIN.equals(sysUser.getUserId())){ + startPage(); + if(UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())){ + Long logOperatorId = sysUser.getOperatorId(); + //运营商看自己的场站 + list = xhpcCommonMapper.getPersonnelStatistics(operatorId, chargingStationId, chargingPileId, type, name,phone,account, 1,logOperatorId,tenantId); + }else{ + //查询赋值的场站 + list = xhpcCommonMapper.getPersonnelStatistics(operatorId, chargingStationId, chargingPileId, type, name,phone,account, 2,sysUserId,tenantId); + } + }else{ + startPage(); + list =xhpcCommonMapper.getPersonnelStatistics(operatorId, chargingStationId, chargingPileId, type, name,phone,account, 0,sysUserId,tenantId); + } + return list; + } + + @Override + public void getPersonnelStatisticsExport(HttpServletResponse response, Long operatorId, Long chargingStationId, Long chargingPileId, Integer type, String name, String phone, String account) throws IOException { + LoginUser loginUser = tokenService.getLoginUser(); + SysUser sysUser = loginUser.getSysUser(); + String tenantId = loginUser.getTenantId(); + Long sysUserId = sysUser.getUserId(); + //获取登陆用户 + List> list =new ArrayList<>(); + if(!UserTypeUtil.SYS_USER_TYPE_ADMIN.equals(sysUser.getUserId())){ + if(UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())){ + Long logOperatorId = sysUser.getOperatorId(); + //运营商看自己的场站 + list = xhpcCommonMapper.getPersonnelStatistics(operatorId, chargingStationId, chargingPileId, type, name,phone,account, 1,logOperatorId,tenantId); + }else{ + //查询赋值的场站 + list = xhpcCommonMapper.getPersonnelStatistics(operatorId, chargingStationId, chargingPileId, type, name,phone,account, 2,sysUserId,tenantId); + } + }else{ + + list =xhpcCommonMapper.getPersonnelStatistics(operatorId, chargingStationId, chargingPileId, type, name,phone,account, 0,sysUserId,tenantId); + } + // 通过工具类创建writer,默认创建xls格式 + BigExcelWriter writer = ExcelUtil.getBigWriter("机构人员统计.xlsx"); + writer.addHeaderAlias("mechanismName", "机构类型"); + writer.addHeaderAlias("account", "机构账号"); + writer.addHeaderAlias("name", "用户名称"); + writer.addHeaderAlias("phone", "手机号"); + writer.addHeaderAlias("number", "充电次数"); + writer.addHeaderAlias("totalPower", "充电度数"); + writer.addHeaderAlias("totalPrice", "充电金额"); + writer.addHeaderAlias("promotionDiscount", "优惠金额"); + writer.setOnlyAlias(true); + // 一次性写出内容,使用默认样式,强制输出标题 + writer.write(list, true); + //out为OutputStream,需要写出到的目标流 + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + + ServletOutputStream out = response.getOutputStream(); + + writer.flush(out, true); + // 关闭writer,释放内存 + writer.close(); + //此处记得关闭输出Servlet流 + IoUtil.close(out); + } } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcInvoiceServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcInvoiceServiceImpl.java index 0450cbb0..aab470e8 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcInvoiceServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcInvoiceServiceImpl.java @@ -458,7 +458,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { */ private String generateRedisKey(XhpcInvoice xhpcInvoice) { - String tenantId = tokenService.getLoginUser().getSysUser().getTenantId(); + String tenantId = xhpcInvoice.getTenantId(); String redisKey = "global:invoice:" + tenantId + ":"; switch (xhpcInvoice.getCreatorType()) { case 0: diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml index ea508282..5ce5ca85 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml @@ -118,4 +118,169 @@ and xcp.tenant_id =#{tenantId} + + + + + diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcOperatorMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcOperatorMapper.xml index bde2e8c7..ad1766f0 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcOperatorMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcOperatorMapper.xml @@ -287,11 +287,10 @@ xo.operator_id_evcs operatorIdEvcs, xdb.dict_value attributenName,`xa`.merger_name mergerName, - GROUP_CONCAT(DISTINCT xi.`url` ORDER BY xi.create_time DESC separator ',') businessLicenseUrl + xo.business_license_id businessLicenseUrl from xhpc_operator `xo` LEFT JOIN xhpc_dict_biz xdb on xdb.`code` = 'operator_attribute' and xdb.dict_key = xo.attribute LEFT JOIN xhpc_area `xa` on `xa`.`code` = xo.area_code - LEFT JOIN xhpc_img xi on FIND_IN_SET(xi.img_id,xo.business_license_id ) where xo.del_flag = 0 and xo.operator_id = #{operatorId} diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcUserMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcUserMapper.xml index 05c0fb83..03d5f904 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcUserMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcUserMapper.xml @@ -325,15 +325,21 @@