diff --git a/sql/v2.1.sql b/sql/v2.1.sql index 575a72ca..ee083f7b 100644 --- a/sql/v2.1.sql +++ b/sql/v2.1.sql @@ -565,4 +565,7 @@ CREATE TABLE `xhpc_message_board_receive_user` DEFAULT CHARSET = utf8mb4 COMMENT ='用来保存每个租户后台显示的用户的信息列表'; ALTER TABLE `ry-cloud`.`t_iccard_info` - ADD COLUMN `tenant_id` varchar(10) NOT NULL DEFAULT '000000' COMMENT '租户id' AFTER `createTime`; \ No newline at end of file + ADD COLUMN `tenant_id` varchar(10) NOT NULL DEFAULT '000000' COMMENT '租户id' AFTER `createTime`; + +ALTER TABLE `xhpc_statistics_station` + ADD COLUMN `source` INT(4) NULL COMMENT '订单来源(0 C端用户 1 流量方用户 2社区用户 3B端用户)' AFTER `tenant_id`; \ No newline at end of file diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java index fc8b02aa..51c91e69 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java @@ -960,6 +960,7 @@ public class XhpcHistoryOrderController extends BaseController { xhpcSt.setHistoryOrderId(xhpc.getHistoryOrderId()); xhpcSt.setChargingPileId(xhpc.getChargingPileId()); xhpcSt.setCreateTime(xhpc.getEndTime()); + xhpcSt.setSource(xhpc.getSource()); xhpcSt.setInternetDegreeCommission(xhpc.getInternetDegreeCommission()); for (int i = type; i <4 ; i++) { xhpcSt.setType(i); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStatisticsController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStatisticsController.java index 52bc164b..7d8a456b 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStatisticsController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStatisticsController.java @@ -227,6 +227,24 @@ public class XhpcStatisticsController extends BaseController { return getDataTable(list); } + /** + * 机构统计 + * @param chargingStationIds 电站id集合 + * @param internetUserId 流量方id + * @param operatorId 运营商id + * @param startTime 订单开始时间 + * @param endTime 订单结束时间 + * @param userId 用户id + * @param type 1 平台 2 运营商 3流量方 + * @param source 订单来源(0 C端用户 1 流量方用户 2社区用户 3B端用户) + * @return + */ + @GetMapping("/getMechanismPage") + public TableDataInfo getMechanismPage(HttpServletRequest request,String chargingStationIds,Long internetUserId, Long operatorId,String startTime, String endTime, @RequestParam("userId") Long userId, @RequestParam("type")Integer type,@RequestParam("source")Integer source) + { + List> list = xhpcStatisticsService.getMechanismPage(request,chargingStationIds,internetUserId,operatorId,startTime,endTime,userId,type,source); + return getDataTable(list); + } // -------- 导出数据 ------------ @@ -320,4 +338,21 @@ public class XhpcStatisticsController extends BaseController { xhpcStatisticsService.terminalIntervalExport(request,response, chargingStationId,terminalId,operatorId,startTime,endTime,userId,type); } + /** + * 机构导出 + * @param chargingStationIds 电站id集合 + * @param internetUserId 流量方id + * @param operatorId 运营商id + * @param startTime 订单开始时间 + * @param endTime 订单结束时间 + * @param userId 用户id + * @param type 1 平台 2 运营商 3流量方 + * @param source 订单来源(0 C端用户 1 流量方用户 2社区用户 3B端用户) + * @return + */ + @GetMapping("/getMechanismPage/export") + public void getMechanismExport(HttpServletRequest request,HttpServletResponse response,String chargingStationIds,Long internetUserId, Long operatorId,String startTime, String endTime, @RequestParam("userId") Long userId, @RequestParam("type")Integer type,@RequestParam("source")Integer source)throws IOException + { + xhpcStatisticsService.getMechanismExport(request,response,chargingStationIds,internetUserId,operatorId,startTime,endTime,userId,type,source); + } } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcStatisticsStation.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcStatisticsStation.java index 4dfe2b6f..9ac9cafe 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcStatisticsStation.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcStatisticsStation.java @@ -132,4 +132,9 @@ public class XhpcStatisticsStation extends BaseEntity { * 租户id */ private String tenantId; + + /** + * 订单来源(0 C端用户 1 流量方用户 2社区用户 3B端用户) + */ + private Integer source; } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcStatisticsServiceMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcStatisticsServiceMapper.java index b36de127..1664f88d 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcStatisticsServiceMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcStatisticsServiceMapper.java @@ -6,6 +6,7 @@ import com.xhpc.order.domain.XhpcStatisticsTimeInterval; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import javax.persistence.criteria.CriteriaBuilder; import java.util.List; import java.util.Map; @@ -128,6 +129,20 @@ public interface XhpcStatisticsServiceMapper { */ List> getTerminalList(@Param("chargingStationId")Long chargingStationId,@Param("userId")Long userId,@Param("type")Integer type,@Param("tenantId")String tenantId); + /** + * 机构统计 + * @param chargingStationIds 电站id集合 + * @param internetUserId 流量方id + * @param operatorId 运营商id + * @param startTime 订单开始时间 + * @param endTime 订单结束时间 + * @param type 1 平台 2 运营商 3流量方 + * @return + */ + List> getMechanismPage(@Param("chargingStationIds") List chargingStationIds, @Param("internetUserId") Long internetUserId, @Param("operatorId") Long operatorId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("type") Integer type, @Param("userId")Long userId, @Param("tenantId")String tenantId,@Param("source")Integer source); + + + /** * 添加时段订单统计 * @param xhpcStatisticsTimeInterval diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcStatisticsService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcStatisticsService.java index 2210ef8f..857b3901 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcStatisticsService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcStatisticsService.java @@ -152,6 +152,23 @@ public interface IXhpcStatisticsService { */ List> getSumSourceList(HttpServletRequest request,String startTime, String endTime, String sourceIds,Long userId,Integer type, String chargingStationIds); + + /** + * 机构统计 + * @param chargingStationIds 电站id集合 + * @param internetUserId 流量方id + * @param operatorId 运营商id + * @param startTime 订单开始时间 + * @param endTime 订单结束时间 + * @param userId 用户id + * @param type 1 平台 2 运营商 3流量方 + * @param source 订单来源(0 C端用户 1 流量方用户 2社区用户 3B端用户) + * @return + */ + List> getMechanismPage(HttpServletRequest request,String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type,Integer source); + + + /** * 添加时段订单统计 * @param xhpcStatisticsTimeInterval @@ -244,5 +261,5 @@ public interface IXhpcStatisticsService { */ void terminalIntervalExport(HttpServletRequest request,HttpServletResponse response, String chargingStationId, String terminalId, Long operatorId, String startTime, String endTime, Long userId, Integer type) throws IOException; - + void getMechanismExport(HttpServletRequest request,HttpServletResponse response,String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type,Integer source) throws IOException ; } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcStatisticsServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcStatisticsServiceImpl.java index 284ca74e..8a425f60 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcStatisticsServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcStatisticsServiceImpl.java @@ -428,6 +428,42 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati return xhpcStatisticsServiceMapper.getSumSourceList(startTime, endTime, sourceList, sysUserId, type,chargingStationIdList,tenantId); } + + @Override + public List> getMechanismPage(HttpServletRequest request, String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type,Integer source) { + + if (getJudge(internetUserId, operatorId, type)){ + return new ArrayList<>(); + } + List chargingStationId =new ArrayList<>(); + if(!"".equals(chargingStationIds) && chargingStationIds !=null){ + chargingStationId= Arrays.asList(chargingStationIds.split(",")); + } + //获取登陆用户 + LoginUser loginUser = tokenService.getLoginUser(request); + 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 = xhpcStatisticsServiceMapper.getMechanismPage(chargingStationId, internetUserId, operatorId, startTime, endTime, 1,logOperatorId,tenantId,source); + }else{ + //查询赋值的场站 + list = xhpcStatisticsServiceMapper.getMechanismPage(chargingStationId, internetUserId, operatorId, startTime, endTime, 2,sysUserId,tenantId,source); + } + }else{ + startPage(); + list =xhpcStatisticsServiceMapper.getMechanismPage(chargingStationId, internetUserId, operatorId, startTime, endTime, 0,sysUserId,tenantId,source); + } + + return list; + } + @Override public void addStatisticsTime(XhpcStatisticsTimeInterval xhpcStatisticsTimeInterval) { xhpcStatisticsServiceMapper.addStatisticsTime(xhpcStatisticsTimeInterval); @@ -756,5 +792,48 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati IoUtil.close(out); } + @Override + public void getMechanismExport(HttpServletRequest request, HttpServletResponse response, String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type, Integer source) throws IOException { + List> list = getMechanismPage(request,chargingStationIds, internetUserId, operatorId, startTime, endTime, userId, type,source); + + // 通过工具类创建writer,默认创建xls格式 + ExcelWriter writer = ExcelUtil.getWriter(true); + writer.addHeaderAlias("internetUserName", "流量方名称"); + writer.addHeaderAlias("chargingDegree", "电量"); + writer.addHeaderAlias("chargingTime", "充电时长(小时)"); + writer.addHeaderAlias("chargingNumber", "充电次数"); + writer.addHeaderAlias("powerPrice", "电费"); + writer.addHeaderAlias("servicePrice", "服务费"); + writer.addHeaderAlias("totalPrice", "订单总价"); + writer.addHeaderAlias("promotionDiscount", "抵扣的总金额"); + writer.addHeaderAlias("actPrice", "用户支付金额"); + writer.addHeaderAlias("actPowerPrice", "运营商电费"); + writer.addHeaderAlias("actServicePrice", "运营商服务费"); + writer.addHeaderAlias("internetCommission", "流量方总金额抽成"); + writer.addHeaderAlias("internetSvcCommission", "流量方服务费抽成"); + writer.addHeaderAlias("platformCommission", "平台总金额抽成"); + writer.addHeaderAlias("platformSvcCommisssion", "平台服务费抽成"); + writer.addHeaderAlias("operationCommission", "运维总金额抽成"); + writer.addHeaderAlias("operationSvcCommission", "运维服务费抽成"); + writer.addHeaderAlias("createTime", "日期"); + + // 默认的,未添加alias的属性也会写出,如果想只写出加了别名的字段,可以调用此方法排除之 + 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-order/src/main/resources/mapper/XhpcStatisticsMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml index e6bd2a26..0e086bf7 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml @@ -420,6 +420,68 @@ + + insert into xhpc_statistics_time_interval @@ -693,7 +755,10 @@ charging_mode, - internet_degree_commission + internet_degree_commission, + + + source, @@ -781,6 +846,9 @@ #{internetDegreeCommission}, + + #{source}, + diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcUserController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcUserController.java index 9a07b170..4f6a66ff 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcUserController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcUserController.java @@ -63,7 +63,7 @@ public class XhpcUserController extends BaseController { return AjaxResult.error("新增用户'" + sysUser.getUserName() + "'失败,登录账号已存在"); } SysRole role = new SysRole(); - role.setRoleName(sysUser.getUserName()); + role.setRoleName("平台用户"); role.setRoleKey(sysUser.getUserName()); role.setRoleSort("1"); iXhpcUserService.insertRole(role); @@ -138,7 +138,7 @@ public class XhpcUserController extends BaseController { return AjaxResult.error("新增用户'" + sysUser.getUserName() + "'失败,登录账号已存在"); } SysRole role = new SysRole(); - role.setRoleName(sysUser.getUserName()); + role.setRoleName("运营商用户"); role.setRoleKey(sysUser.getUserName()); role.setRoleSort("1"); iXhpcUserService.insertRole(role); @@ -237,9 +237,6 @@ public class XhpcUserController extends BaseController { return AjaxResult.success(); } - - - private void addXhpcDataDimension(Long[] menuIds,Long userId){ if(menuIds !=null){ //添加数据维度