New file |
| | |
| | | package com.ruoyi.order.api.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/5/9 11:35 |
| | | */ |
| | | @Data |
| | | @TableName("t_charging_order_summary_data") |
| | | public class TChargingOrderSummaryData { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.NONE) |
| | | private Long id; |
| | | /** |
| | | * 充电订单id |
| | | */ |
| | | @TableField("charging_order_id") |
| | | private Long chargingOrderId; |
| | | /** |
| | | * 充电时长(s) |
| | | */ |
| | | @TableField("charging_duration") |
| | | private Long chargingDuration; |
| | | /** |
| | | * 充电度数 |
| | | */ |
| | | @TableField("charging_capacity") |
| | | private BigDecimal chargingCapacity; |
| | | /** |
| | | * 收入 |
| | | */ |
| | | @TableField("income") |
| | | private BigDecimal income; |
| | | /** |
| | | * 电费 |
| | | */ |
| | | @TableField("electric_price") |
| | | private BigDecimal electricPrice; |
| | | /** |
| | | * 服务费 |
| | | */ |
| | | @TableField("service_price") |
| | | private BigDecimal servicePrice; |
| | | |
| | | |
| | | } |
| | |
| | | claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId); |
| | | claimsMap.put(SecurityConstants.USER_TYPE, "system"); |
| | | claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName); |
| | | |
| | | String token1 = JwtUtils.createToken(claimsMap); |
| | | String userKey = getUserKey(loginUser.getUserid()); |
| | | redisService.setCacheObject(userKey, token1, expireTime, TimeUnit.MINUTES); |
| | | // 接口返回信息 |
| | | Map<String, Object> rspMap = new HashMap<String, Object>(); |
| | | rspMap.put("access_token", token1); |
| | | rspMap.put("access_token", JwtUtils.createToken(claimsMap)); |
| | | rspMap.put("expires_in", expireTime); |
| | | return rspMap; |
| | | } |
| | |
| | | addHeader(mutate, SecurityConstants.DETAILS_USER_ID, userid); |
| | | addHeader(mutate, SecurityConstants.DETAILS_USERNAME, username); |
| | | addHeader(mutate, SecurityConstants.USER_TYPE, userType); |
| | | //管理后台记录用户最后一次的操作时间,用于判定30分钟无操作后删除token,退出登录 |
| | | if("system".equals(userType)){ |
| | | addLastTime(userid, url); |
| | | } |
| | | |
| | | // 内部请求来源参数清除 |
| | | removeHeader(mutate, SecurityConstants.FROM_SOURCE); |
| | | return chain.filter(exchange.mutate().request(mutate.build()).build()); |
| | |
| | | private Mono<Void> unauthorizedResponse(ServerWebExchange exchange, String msg) { |
| | | log.error("[鉴权异常处理]请求路径:{}", exchange.getRequest().getPath() + "\n" + msg); |
| | | return ServletUtils.webFluxResponseWriter(exchange.getResponse(), msg, HttpStatus.UNAUTHORIZED); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 记录用户最后一次操作的时间 |
| | | * @param userid |
| | | * @param url |
| | | */ |
| | | private void addLastTime(String userid, String url){ |
| | | Object lastTime = redisService.getCacheObject("lastTime:" + userid); |
| | | if(null == lastTime){ |
| | | redisService.setCacheObject("lastTime:" + userid, System.currentTimeMillis()); |
| | | }else{ |
| | | Long last = Long.valueOf(lastTime.toString()); |
| | | //操作登录或者时间差值小于30分钟,写入新的数据到缓存中 |
| | | if("/auth/login".equals(url) || System.currentTimeMillis() - last < 1800000L){ |
| | | redisService.setCacheObject("lastTime:" + userid, System.currentTimeMillis()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | @MapperScan({"com.ruoyi.system.mapper"}) |
| | | @EnableCustomSwagger2 |
| | | @EnableRyFeignClients |
| | | @EnableScheduling//开启定时任务 |
| | | @SpringBootApplication |
| | | @EnableTransactionManagement |
| | | public class RuoYiSystemApplication |
| | |
| | | <result property="updateTime" column="update_time" /> |
| | | <result property="forbiddenRemark" column="forbidden_remark"/> |
| | | <result property="remark" column="remark" /> |
| | | <result property="passWordUpdate" column="passWordUpdate" /> |
| | | <result property="roleType" column="roleType" /> |
| | | <result property="objectId" column="objectId" /> |
| | | <association property="dept" column="dept_id" javaType="com.ruoyi.system.api.domain.SysDept" resultMap="deptResult" /> |
| | |
| | | </resultMap> |
| | | |
| | | <sql id="selectUserVo"> |
| | | select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, |
| | | select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.passWordUpdate, |
| | | d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status, |
| | | r.role_id, r.role_name, r.role_key, r.data_scope, r.status as role_status ,u.roleType as roleType,u.objectId AS objectId |
| | | from sys_user u |
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.chargingPile.api.dto.CheckChargingStrategyDTO; |
| | | import com.ruoyi.chargingPile.api.feignClient.AccountingStrategyDetailClient; |
| | | import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient; |
| | | import com.ruoyi.chargingPile.api.model.TAccountingStrategyDetail; |
| | | import com.ruoyi.chargingPile.api.vo.UpdateChargingPileStatusVo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.integration.api.model.*; |
| | |
| | | import org.apache.rocketmq.client.producer.SendResult; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * iotda消息监听 |
| | |
| | | private IotMessageProduce iotMessageProduce; |
| | | @Resource |
| | | private AccountingStrategyDetailClient accountingStrategyDetailClient; |
| | | |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Resource |
| | | private ChargingPileClient chargingPileClient; |
| | | |
| | | |
| | | |
| | |
| | | break; |
| | | case SendTagConstant.PING: |
| | | PingMessage pingMessage = JSON.parseObject(content.toJSONString(),PingMessage.class); |
| | | sendResult = enhanceProduce.pingMessage(pingMessage); |
| | | //存储缓存中,5分钟有效 |
| | | redisTemplate.opsForValue().set("ping:" + pingMessage.getCharging_pile_code() + pingMessage.getCharging_gun_code(), pingMessage, 5, TimeUnit.MINUTES); |
| | | sendResult = null; |
| | | // sendResult = enhanceProduce.pingMessage(pingMessage); |
| | | // chargingMessage.setPingMessage(pingMessage); |
| | | // chargingMessageUtil.handleMessage(chargingMessage); |
| | | // 响应硬件 |
| | |
| | | pong.setCharging_gun_code(pingMessage.getCharging_gun_code()); |
| | | pong.setCharging_gun_status(0); |
| | | iotMessageProduce.sendMessage(pong.getCharging_pile_code(), ServiceIdMenu.PONG.getKey(), messageUtil.pong(pong)); |
| | | |
| | | UpdateChargingPileStatusVo vo1 = new UpdateChargingPileStatusVo(); |
| | | vo1.setGun_code(pingMessage.getCharging_gun_code()); |
| | | vo1.setPile_code(pingMessage.getCharging_pile_code()); |
| | | vo1.setStatus(pingMessage.getCharging_gun_status()); |
| | | chargingPileClient.updateChargingPileStatus(vo1); |
| | | // 监管平台推送充电设备状态 |
| | | String gunCode = pingMessage.getCharging_pile_code() + pingMessage.getCharging_gun_code(); |
| | | ChargingMessage chargingMessage1 = new ChargingMessage(); |
| | | chargingMessage1.setServiceId(SendTagConstant.GUN_STATUS); |
| | | GunStatusMessage gunStatusMessage = new GunStatusMessage(); |
| | | gunStatusMessage.setFullNumber(gunCode); |
| | | chargingMessage1.setGunStatusMessage(gunStatusMessage); |
| | | sendResult = enhanceProduce.gunStatusMessage(chargingMessage1); |
| | | |
| | | |
| | | // sendResult = enhanceProduce.chargingMessage(chargingMessage); |
| | | break; |
| | | case SendTagConstant.END_CHARGE: |
| | |
| | | @PostMapping(value = "/work/chargeDetail") |
| | | @ApiOperation(value = "运营情况", tags = {"管理后台-工作台"}) |
| | | public R workCharge(@RequestBody ChargingDetailQueryDto statisticsQueryDto) { |
| | | List<Integer> siteIds = new ArrayList<>(); |
| | | if (statisticsQueryDto.getSiteId() == null) { |
| | | Long userId = tokenService.getLoginUser().getUserid(); |
| | | //获取当前登录的siteIds |
| | | List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData(); |
| | | for (GetSiteListDTO datum : data) { |
| | | siteIds.add(datum.getId()); |
| | | } |
| | | } else { |
| | | siteIds.add(statisticsQueryDto.getSiteId()); |
| | | } |
| | | if (statisticsQueryDto.getDayType()==1) { |
| | | List<Map<String,Object>> charMap1 = chargingOrderService.getHourType(siteIds,statisticsQueryDto); |
| | | List<Map<String, Object>> charMap = new ArrayList<>(); |
| | | // 生成从 "00:00" 到 "23:00" 的时间数据 |
| | | for (int hour = 0; hour < 24; hour++) { |
| | | String time = String.format("%02d:00", hour); |
| | | Map<String, Object> mapWithTimeValue = findMapWithTimeValue(charMap1, time); |
| | | if (mapWithTimeValue!=null){ |
| | | charMap.add(mapWithTimeValue); |
| | | }else { |
| | | Map<String, Object> timeMap = new HashMap<>(); |
| | | timeMap.put("time", time); // 初始化值为 null |
| | | timeMap.put("electrovalence", 0); |
| | | timeMap.put("orderCount", 0); |
| | | timeMap.put("servicecharge", 0); |
| | | timeMap.put("electricity", 0); |
| | | charMap.add(timeMap); |
| | | try { |
| | | List<Integer> siteIds = new ArrayList<>(); |
| | | if (statisticsQueryDto.getSiteId() == null) { |
| | | Long userId = tokenService.getLoginUser().getUserid(); |
| | | //获取当前登录的siteIds |
| | | List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData(); |
| | | for (GetSiteListDTO datum : data) { |
| | | siteIds.add(datum.getId()); |
| | | } |
| | | } else { |
| | | siteIds.add(statisticsQueryDto.getSiteId()); |
| | | } |
| | | return R.ok(charMap); |
| | | }else if (statisticsQueryDto.getDayType()==2){ |
| | | // 假设 chargingOrderService.getDateType() 返回的是按天的数据 |
| | | List<Map<String, Object>> charMap1 = chargingOrderService.getDateType(siteIds, statisticsQueryDto); |
| | | |
| | | // 解析 startTime 和 endTime 为 LocalDate |
| | | LocalDate startDate = statisticsQueryDto.getStartTime(); |
| | | LocalDate endDate = statisticsQueryDto.getEndTime(); |
| | | |
| | | List<Map<String, Object>> dateRangeStatistics = new ArrayList<>(); |
| | | |
| | | // 遍历日期范围 |
| | | while (!startDate.isAfter(endDate)) { |
| | | String formattedDate = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | Map<String, Object> dailyStats = findMapWithDateValue(charMap1, formattedDate); |
| | | |
| | | if (dailyStats != null) { |
| | | dateRangeStatistics.add(dailyStats); |
| | | } else { |
| | | Map<String, Object> dateMap = new HashMap<>(); |
| | | dateMap.put("time", formattedDate); |
| | | dateMap.put("electrovalence", 0); |
| | | dateMap.put("orderCount", 0); |
| | | dateMap.put("servicecharge", 0); |
| | | dateMap.put("electricity", 0); |
| | | dateRangeStatistics.add(dateMap); |
| | | if (statisticsQueryDto.getDayType()==1) { |
| | | List<Map<String,Object>> charMap1 = chargingOrderService.getHourType(siteIds,statisticsQueryDto); |
| | | List<Map<String, Object>> charMap = new ArrayList<>(); |
| | | // 生成从 "00:00" 到 "23:00" 的时间数据 |
| | | for (int hour = 0; hour < 24; hour++) { |
| | | String time = String.format("%02d:00", hour); |
| | | Map<String, Object> mapWithTimeValue = findMapWithTimeValue(charMap1, time); |
| | | if (mapWithTimeValue!=null){ |
| | | charMap.add(mapWithTimeValue); |
| | | }else { |
| | | Map<String, Object> timeMap = new HashMap<>(); |
| | | timeMap.put("time", time); // 初始化值为 null |
| | | timeMap.put("electrovalence", 0); |
| | | timeMap.put("orderCount", 0); |
| | | timeMap.put("servicecharge", 0); |
| | | timeMap.put("electricity", 0); |
| | | charMap.add(timeMap); |
| | | } |
| | | } |
| | | |
| | | // 移动到下一天 |
| | | startDate = startDate.plusDays(1); |
| | | } |
| | | return R.ok(charMap); |
| | | }else if (statisticsQueryDto.getDayType()==2){ |
| | | // 假设 chargingOrderService.getDateType() 返回的是按天的数据 |
| | | List<Map<String, Object>> charMap1 = chargingOrderService.getDateType(siteIds, statisticsQueryDto); |
| | | |
| | | // 解析 startTime 和 endTime 为 LocalDate |
| | | LocalDate startDate = statisticsQueryDto.getStartTime(); |
| | | LocalDate endDate = statisticsQueryDto.getEndTime(); |
| | | |
| | | List<Map<String, Object>> dateRangeStatistics = new ArrayList<>(); |
| | | |
| | | // 遍历日期范围 |
| | | while (!startDate.isAfter(endDate)) { |
| | | String formattedDate = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | Map<String, Object> dailyStats = findMapWithDateValue(charMap1, formattedDate); |
| | | |
| | | if (dailyStats != null) { |
| | | dateRangeStatistics.add(dailyStats); |
| | | } else { |
| | | Map<String, Object> dateMap = new HashMap<>(); |
| | | dateMap.put("time", formattedDate); |
| | | dateMap.put("electrovalence", 0); |
| | | dateMap.put("orderCount", 0); |
| | | dateMap.put("servicecharge", 0); |
| | | dateMap.put("electricity", 0); |
| | | dateRangeStatistics.add(dateMap); |
| | | } |
| | | |
| | | // 移动到下一天 |
| | | startDate = startDate.plusDays(1); |
| | | } |
| | | |
| | | // return dateRangeStatistics; |
| | | return R.ok(dateRangeStatistics); |
| | | }else if (statisticsQueryDto.getDayType()==3){ |
| | | List<Map<String,Object>> charMap1 = chargingOrderService.getMonthType(siteIds,statisticsQueryDto); |
| | | // 解析 startTime 和 endTime 为 LocalDate |
| | | LocalDate startDate = statisticsQueryDto.getStartTime(); |
| | | LocalDate endDate = statisticsQueryDto.getEndTime(); |
| | | |
| | | List<Map<String, Object>> dateRangeStatistics = new ArrayList<>(); |
| | | |
| | | // 遍历日期范围 |
| | | while (!startDate.isAfter(endDate)) { |
| | | String formattedDate = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM")); |
| | | Map<String, Object> dailyStats = findMapWithDateValue(charMap1, formattedDate); |
| | | |
| | | if (dailyStats != null) { |
| | | dateRangeStatistics.add(dailyStats); |
| | | } else { |
| | | Map<String, Object> dateMap = new HashMap<>(); |
| | | dateMap.put("time", formattedDate); |
| | | dateMap.put("electrovalence", 0); |
| | | dateMap.put("orderCount", 0); |
| | | dateMap.put("servicecharge", 0); |
| | | dateMap.put("electricity", 0); |
| | | dateRangeStatistics.add(dateMap); |
| | | return R.ok(dateRangeStatistics); |
| | | }else if (statisticsQueryDto.getDayType()==3){ |
| | | List<Map<String,Object>> charMap1 = chargingOrderService.getMonthType(siteIds,statisticsQueryDto); |
| | | // 解析 startTime 和 endTime 为 LocalDate |
| | | LocalDate startDate = statisticsQueryDto.getStartTime(); |
| | | LocalDate endDate = statisticsQueryDto.getEndTime(); |
| | | |
| | | List<Map<String, Object>> dateRangeStatistics = new ArrayList<>(); |
| | | |
| | | // 遍历日期范围 |
| | | while (!startDate.isAfter(endDate)) { |
| | | String formattedDate = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM")); |
| | | Map<String, Object> dailyStats = findMapWithDateValue(charMap1, formattedDate); |
| | | |
| | | if (dailyStats != null) { |
| | | dateRangeStatistics.add(dailyStats); |
| | | } else { |
| | | Map<String, Object> dateMap = new HashMap<>(); |
| | | dateMap.put("time", formattedDate); |
| | | dateMap.put("electrovalence", 0); |
| | | dateMap.put("orderCount", 0); |
| | | dateMap.put("servicecharge", 0); |
| | | dateMap.put("electricity", 0); |
| | | dateRangeStatistics.add(dateMap); |
| | | } |
| | | |
| | | // 移动到下一天 |
| | | startDate = startDate.plusMonths(1); |
| | | } |
| | | |
| | | // 移动到下一天 |
| | | startDate = startDate.plusMonths(1); |
| | | return R.ok(dateRangeStatistics); |
| | | |
| | | } |
| | | return R.ok(dateRangeStatistics); |
| | | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok(); |
| | | |
| | |
| | | return chargingOrderService.pushOrderInfo(code); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加汇总数据(临时) |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping(value = "/addChargingOrderSummaryData") |
| | | public R addChargingOrderSummaryData(){ |
| | | return chargingOrderService.addChargingOrderSummaryData(); |
| | | } |
| | | } |
| | |
| | | @Param("pageCurr") Integer pageCurr, @Param("pageSize") Integer pageSize); |
| | | |
| | | List<ChargingOrderVO> chargingOrder(@Param("pageInfo") PageInfo<ChargingOrderVO> pageInfo, @Param("req") ChargingOrderQuery dto, @Param("startTime1")String startTime1, @Param("startTime2")String startTime2,@Param("endTime1") String endTime1,@Param("endTime2") String endTime11); |
| | | List<ChargingOrderVO> chargingOrderNolimit( @Param("req") ChargingOrderQuery dto, @Param("startTime1")String startTime1, @Param("startTime2")String startTime2,@Param("endTime1") String endTime1,@Param("endTime2") String endTime11); |
| | | Map<String, Object> chargingOrderNolimit( @Param("req") ChargingOrderQuery dto, @Param("startTime1")String startTime1, @Param("startTime2")String startTime2,@Param("endTime1") String endTime1,@Param("endTime2") String endTime11); |
| | | |
| | | List<PayOrderDto> payOrderQuery(@Param("pageInfo")PageInfo<PayOrderDto> pageInfo,@Param("data") PayOrderQueryDto payOrderQueryDto); |
| | | |
New file |
| | |
| | | package com.ruoyi.order.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.order.api.model.TChargingOrderSummaryData; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/5/9 11:39 |
| | | */ |
| | | public interface TChargingOrderSummaryDataMapper extends BaseMapper<TChargingOrderSummaryData> { |
| | | } |
New file |
| | |
| | | package com.ruoyi.order.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.order.api.model.TChargingOrderSummaryData; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/5/9 11:39 |
| | | */ |
| | | public interface ITChargingOrderSummaryDataService extends IService<TChargingOrderSummaryData> { |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | R pushOrderInfo(String code); |
| | | |
| | | |
| | | R addChargingOrderSummaryData(); |
| | | } |
| | |
| | | |
| | | @Resource |
| | | private TransactionRecordClient transactionRecordClient; |
| | | |
| | | @Resource |
| | | private ITChargingOrderSummaryDataService chargingOrderSummaryDataService; |
| | | |
| | | |
| | | |
| | |
| | | // .eq(TChargingOrderRefund::getRefundStatus,2).list(); |
| | | |
| | | |
| | | List<ChargingOrderVO> list1 = this.baseMapper.chargingOrderNolimit(dto,startTime1,startTime2,endTime1,endTime2); |
| | | for (ChargingOrderVO chargingOrderVO : list1) { |
| | | if(null == chargingOrderVO.getStatus() || 5 != chargingOrderVO.getStatus()){ |
| | | continue; |
| | | } |
| | | List<TChargingOrderAccountingStrategy> list4 = list3.stream().filter(e -> e.getChargingOrderId().equals(chargingOrderVO.getId())).collect(Collectors.toList()); |
| | | BigDecimal electronic_reduce = list4.stream().map(TChargingOrderAccountingStrategy::getPeriodElectricPrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal service_reduce = list4.stream().map(TChargingOrderAccountingStrategy::getPeriodServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal chargingCapacity = list4.stream().map(TChargingOrderAccountingStrategy::getChargingCapacity).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | electronicMoney = electronicMoney.add(electronic_reduce); |
| | | total = total.add(chargingCapacity); |
| | | if (!chargingOrderVO.getOrderSource().equals(2)) { |
| | | serviceMoney = serviceMoney.add(service_reduce); |
| | | paymentMoney = paymentMoney.add(electronic_reduce).add(service_reduce); |
| | | }else{ |
| | | serviceMoney = serviceMoney.add(service_reduce.multiply(new BigDecimal("0.8"))); |
| | | paymentMoney = paymentMoney.add(electronic_reduce).add(service_reduce.multiply(new BigDecimal("0.8"))); |
| | | } |
| | | if (chargingOrderVO.getStartTime()!=null && chargingOrderVO.getEndTime()!=null){ |
| | | LocalDateTime startTime = chargingOrderVO.getStartTime(); |
| | | LocalDateTime endTime = chargingOrderVO.getEndTime(); |
| | | // 计算时间差 单位秒 |
| | | long between = ChronoUnit.SECONDS.between(startTime, endTime); |
| | | time+=between; |
| | | } |
| | | // List<TChargingOrderRefund> list2 = chargingOrderRefunds.stream().filter(e -> e.getChargingOrderId() != null && e.getChargingOrderId().equals(chargingOrderVO.getId())) |
| | | // .collect(Collectors.toList()); |
| | | // for (TChargingOrderRefund tChargingOrderRefund : list2) { |
| | | // refundMoney = refundMoney.add(tChargingOrderRefund.getRefundTotalAmount()); |
| | | Map<String, Object> map = this.baseMapper.chargingOrderNolimit(dto,startTime1,startTime2,endTime1,endTime2); |
| | | // for (ChargingOrderVO chargingOrderVO : list1) { |
| | | // if(null == chargingOrderVO.getStatus() || 5 != chargingOrderVO.getStatus()){ |
| | | // continue; |
| | | // } |
| | | // List<TChargingOrderAccountingStrategy> list4 = list3.stream().filter(e -> e.getChargingOrderId().equals(chargingOrderVO.getId())).collect(Collectors.toList()); |
| | | // BigDecimal electronic_reduce = list4.stream().map(TChargingOrderAccountingStrategy::getPeriodElectricPrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // BigDecimal service_reduce = list4.stream().map(TChargingOrderAccountingStrategy::getPeriodServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // BigDecimal chargingCapacity = list4.stream().map(TChargingOrderAccountingStrategy::getChargingCapacity).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // electronicMoney = electronicMoney.add(electronic_reduce); |
| | | // total = total.add(chargingCapacity); |
| | | // if (!chargingOrderVO.getOrderSource().equals(2)) { |
| | | // serviceMoney = serviceMoney.add(service_reduce); |
| | | // paymentMoney = paymentMoney.add(electronic_reduce).add(service_reduce); |
| | | // }else{ |
| | | // serviceMoney = serviceMoney.add(service_reduce.multiply(new BigDecimal("0.8"))); |
| | | // paymentMoney = paymentMoney.add(electronic_reduce).add(service_reduce.multiply(new BigDecimal("0.8"))); |
| | | // } |
| | | // if (chargingOrderVO.getStartTime()!=null && chargingOrderVO.getEndTime()!=null){ |
| | | // LocalDateTime startTime = chargingOrderVO.getStartTime(); |
| | | // LocalDateTime endTime = chargingOrderVO.getEndTime(); |
| | | // // 计算时间差 单位秒 |
| | | // long between = ChronoUnit.SECONDS.between(startTime, endTime); |
| | | // time+=between; |
| | | // } |
| | | //// List<TChargingOrderRefund> list2 = chargingOrderRefunds.stream().filter(e -> e.getChargingOrderId() != null && e.getChargingOrderId().equals(chargingOrderVO.getId())) |
| | | //// .collect(Collectors.toList()); |
| | | //// for (TChargingOrderRefund tChargingOrderRefund : list2) { |
| | | //// refundMoney = refundMoney.add(tChargingOrderRefund.getRefundTotalAmount()); |
| | | //// } |
| | | // } |
| | | if(null != map){ |
| | | tCharingOrderVO.setTotal(map.get("total")==null?BigDecimal.ZERO:(BigDecimal) map.get("total")); |
| | | tCharingOrderVO.setTime(map.get("time")==null?0L:(Long) map.get("time")); |
| | | tCharingOrderVO.setIncome((map.get("paymentMoney")==null?BigDecimal.ZERO:(BigDecimal) map.get("paymentMoney")).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | tCharingOrderVO.setElectronicMoney((map.get("electronicMoney")==null?BigDecimal.ZERO:(BigDecimal) map.get("electronicMoney")).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | tCharingOrderVO.setServiceMoney((map.get("serviceMoney")==null?BigDecimal.ZERO:(BigDecimal) map.get("serviceMoney")).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | }else{ |
| | | tCharingOrderVO.setTotal(BigDecimal.ZERO); |
| | | tCharingOrderVO.setTime(0L); |
| | | tCharingOrderVO.setIncome(BigDecimal.ZERO); |
| | | tCharingOrderVO.setElectronicMoney(BigDecimal.ZERO); |
| | | tCharingOrderVO.setServiceMoney(BigDecimal.ZERO); |
| | | } |
| | | tCharingOrderVO.setTotal(total); |
| | | tCharingOrderVO.setTime(time); |
| | | tCharingOrderVO.setIncome(paymentMoney.setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | tCharingOrderVO.setElectronicMoney(electronicMoney.setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | tCharingOrderVO.setServiceMoney(serviceMoney.setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | pageInfo.setRecords(list); |
| | | tCharingOrderVO.setList(pageInfo); |
| | | return tCharingOrderVO; |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | //添加汇总统计数据 |
| | | List<TChargingOrderAccountingStrategy> list4 = chargingOrderAccountingStrategyService.list(new QueryWrapper<TChargingOrderAccountingStrategy>().eq("charging_order_id", chargingOrder.getId())); |
| | | BigDecimal electronic_reduce = list4.stream().map(TChargingOrderAccountingStrategy::getPeriodElectricPrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal service_reduce = list4.stream().map(TChargingOrderAccountingStrategy::getPeriodServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal chargingCapacity = list4.stream().map(TChargingOrderAccountingStrategy::getChargingCapacity).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal serviceMoney = BigDecimal.ZERO; |
| | | BigDecimal paymentMoney = BigDecimal.ZERO; |
| | | long time = 0; |
| | | if (!chargingOrder.getOrderSource().equals(2)) { |
| | | serviceMoney = serviceMoney.add(service_reduce); |
| | | paymentMoney = paymentMoney.add(electronic_reduce).add(service_reduce); |
| | | }else{ |
| | | serviceMoney = serviceMoney.add(service_reduce.multiply(new BigDecimal("0.8"))); |
| | | paymentMoney = paymentMoney.add(electronic_reduce).add(service_reduce.multiply(new BigDecimal("0.8"))); |
| | | } |
| | | if (chargingOrder.getStartTime()!=null && chargingOrder.getEndTime()!=null){ |
| | | LocalDateTime startTime = chargingOrder.getStartTime(); |
| | | LocalDateTime endTime = chargingOrder.getEndTime(); |
| | | // 计算时间差 单位秒 |
| | | time = ChronoUnit.SECONDS.between(startTime, endTime); |
| | | } |
| | | TChargingOrderSummaryData summaryData = new TChargingOrderSummaryData(); |
| | | summaryData.setChargingOrderId(chargingOrder.getId()); |
| | | summaryData.setChargingCapacity(chargingCapacity); |
| | | summaryData.setChargingDuration(time); |
| | | summaryData.setIncome(paymentMoney.setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | summaryData.setElectricPrice(electronic_reduce.setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | summaryData.setServicePrice(serviceMoney.setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | chargingOrderSummaryDataService.save(summaryData); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | tcecClient.notificationChargeOrderInfo(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId()); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public R addChargingOrderSummaryData(){ |
| | | List<TChargingOrderAccountingStrategy> list3 = chargingOrderAccountingStrategyService.list(); |
| | | List<TChargingOrder> list1 = this.list(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getDelFlag, 0)); |
| | | for (TChargingOrder chargingOrderVO : list1) { |
| | | if(null == chargingOrderVO.getStatus() || 5 != chargingOrderVO.getStatus()){ |
| | | continue; |
| | | } |
| | | List<TChargingOrderAccountingStrategy> list4 = list3.stream().filter(e -> e.getChargingOrderId().equals(chargingOrderVO.getId())).collect(Collectors.toList()); |
| | | BigDecimal electronic_reduce = list4.stream().map(TChargingOrderAccountingStrategy::getPeriodElectricPrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal service_reduce = list4.stream().map(TChargingOrderAccountingStrategy::getPeriodServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal chargingCapacity = list4.stream().map(TChargingOrderAccountingStrategy::getChargingCapacity).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal serviceMoney = new BigDecimal("0"); |
| | | BigDecimal paymentMoney = new BigDecimal("0"); |
| | | if (!chargingOrderVO.getOrderSource().equals(2)) { |
| | | serviceMoney = serviceMoney.add(service_reduce); |
| | | paymentMoney = paymentMoney.add(electronic_reduce).add(service_reduce); |
| | | }else{ |
| | | serviceMoney = serviceMoney.add(service_reduce.multiply(new BigDecimal("0.8"))); |
| | | paymentMoney = paymentMoney.add(electronic_reduce).add(service_reduce.multiply(new BigDecimal("0.8"))); |
| | | } |
| | | Long time = 0L; |
| | | if (chargingOrderVO.getStartTime()!=null && chargingOrderVO.getEndTime()!=null){ |
| | | LocalDateTime startTime = chargingOrderVO.getStartTime(); |
| | | LocalDateTime endTime = chargingOrderVO.getEndTime(); |
| | | // 计算时间差 单位秒 |
| | | long between = ChronoUnit.SECONDS.between(startTime, endTime); |
| | | time+=between; |
| | | } |
| | | |
| | | TChargingOrderSummaryData summaryData = new TChargingOrderSummaryData(); |
| | | summaryData.setChargingOrderId(chargingOrderVO.getId()); |
| | | summaryData.setChargingCapacity(chargingCapacity); |
| | | summaryData.setChargingDuration(time); |
| | | summaryData.setIncome(paymentMoney.setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | summaryData.setElectricPrice(electronic_reduce.setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | summaryData.setServicePrice(serviceMoney.setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | chargingOrderSummaryDataService.save(summaryData); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.order.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.order.api.model.TChargingOrderSummaryData; |
| | | import com.ruoyi.order.mapper.TChargingOrderSummaryDataMapper; |
| | | import com.ruoyi.order.service.ITChargingOrderSummaryDataService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/5/9 11:40 |
| | | */ |
| | | @Service |
| | | public class TChargingOrderSummaryDataServiceImpl extends ServiceImpl<TChargingOrderSummaryDataMapper, TChargingOrderSummaryData> implements ITChargingOrderSummaryDataService { |
| | | } |
| | |
| | | |
| | | </select> |
| | | <select id="getHourType" resultType="java.util.Map"> |
| | | select |
| | | aa.time, |
| | | sum(aa.servicecharge) as servicecharge, |
| | | sum(aa.electrovalence) as electrovalence, |
| | | sum(aa.electricity) as electricity, |
| | | count(1) as orderCount |
| | | from ( |
| | | SELECT |
| | | DATE_FORMAT( |
| | | DATE_FORMAT( |
| | | <if test="statisticsQueryDto.type == 1"> |
| | | a.start_time |
| | | </if> |
| | | <if test="statisticsQueryDto.type == 2"> |
| | | a.end_time |
| | | </if> |
| | | , '%H:00' ) as time, |
| | | SUM(CASE |
| | | , '%H:00') as time, |
| | | (CASE |
| | | WHEN a.order_source = 0 THEN b.period_service_price |
| | | WHEN a.order_source = 1 THEN b.period_service_price |
| | | ELSE b.period_service_price * 0.8 |
| | | END) as servicecharge, |
| | | SUM(b.period_electric_price) as electrovalence, |
| | | SUM(b.charging_capacity) as electricity, |
| | | count(1) as orderCount |
| | | (b.period_electric_price) as electrovalence, |
| | | (b.charging_capacity) as electricity |
| | | FROM |
| | | t_charging_order a |
| | | t_charging_order a |
| | | left join (select charging_order_id, sum(period_electric_price) as period_electric_price, sum(period_service_price) as period_service_price, sum(charging_capacity) as charging_capacity, sum(period_electric_price + period_service_price) as money from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id) |
| | | WHERE a.del_flag = 0 and a.status = 5 and a.recharge_payment_status = 2 and DATE( |
| | | WHERE a.del_flag = 0 and a.status = 5 and a.recharge_payment_status = 2 and DATE_FORMAT( |
| | | <if test="statisticsQueryDto.type == 1"> |
| | | a.create_time |
| | | </if> |
| | | <if test="statisticsQueryDto.type == 2"> |
| | | a.end_time |
| | | </if> |
| | | ) = #{statisticsQueryDto.hourDate} |
| | | , '%Y-%m-%d') = #{statisticsQueryDto.hourDate} |
| | | <if test="siteIds != null and siteIds.size() > 0"> |
| | | and a.site_id IN |
| | | <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> |
| | | #{siteId} |
| | | </foreach> |
| | | </if> |
| | | GROUP BY |
| | | time |
| | | ORDER BY |
| | | time |
| | | ) as aa GROUP BY aa.time ORDER BY aa.time |
| | | </select> |
| | | <select id="getDateType" resultType="java.util.Map"> |
| | | select |
| | | aa.time, |
| | | sum(aa.servicecharge) as servicecharge, |
| | | sum(aa.electrovalence) as electrovalence, |
| | | sum(aa.electricity) as electricity, |
| | | count(1) as orderCount |
| | | from ( |
| | | SELECT |
| | | DATE_FORMAT( |
| | | <if test="statisticsQueryDto.type == 1"> |
| | |
| | | <if test="statisticsQueryDto.type == 2"> |
| | | a.end_time |
| | | </if> |
| | | , '%Y-%m-%d' ) as time, |
| | | SUM(CASE |
| | | , '%Y-%m-%d') as time, |
| | | (CASE |
| | | WHEN a.order_source = 0 THEN b.period_service_price |
| | | WHEN a.order_source = 1 THEN b.period_service_price |
| | | ELSE b.period_service_price * 0.8 |
| | | END) as servicecharge, |
| | | SUM(b.period_electric_price) as electrovalence, |
| | | SUM(b.charging_capacity) as electricity, |
| | | count(1) as orderCount |
| | | (b.period_electric_price) as electrovalence, |
| | | (b.charging_capacity) as electricity |
| | | FROM |
| | | t_charging_order a |
| | | left join (select charging_order_id, sum(period_electric_price) as period_electric_price, sum(period_service_price) as period_service_price, sum(charging_capacity) as charging_capacity, sum(period_electric_price + period_service_price) as money from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id) |
| | | WHERE a.del_flag = 0 and a.status = 5 and a.recharge_payment_status = 2 and DATE( |
| | | WHERE a.del_flag = 0 and a.status = 5 and a.recharge_payment_status = 2 and DATE_FORMAT( |
| | | <if test="statisticsQueryDto.type == 1"> |
| | | a.start_time |
| | | </if> |
| | | <if test="statisticsQueryDto.type == 2"> |
| | | a.end_time |
| | | </if> |
| | | ) between #{statisticsQueryDto.startTime} and #{statisticsQueryDto.endTime} |
| | | , '%Y-%m-%d') between #{statisticsQueryDto.startTime} and #{statisticsQueryDto.endTime} |
| | | <if test="siteIds != null and siteIds.size() > 0"> |
| | | and a.site_id IN |
| | | <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> |
| | | #{siteId} |
| | | </foreach> |
| | | </if> |
| | | GROUP BY |
| | | time |
| | | ORDER BY |
| | | time |
| | | ) as aa GROUP BY aa.time ORDER BY aa.time |
| | | </select> |
| | | <select id="getMonthType" resultType="java.util.Map"> |
| | | select |
| | | aa.time, |
| | | sum(aa.servicecharge) as servicecharge, |
| | | sum(aa.electrovalence) as electrovalence, |
| | | sum(aa.electricity) as electricity, |
| | | count(1) as orderCount |
| | | from ( |
| | | SELECT |
| | | DATE_FORMAT( |
| | | <if test="statisticsQueryDto.type == 1"> |
| | |
| | | <if test="statisticsQueryDto.type == 2"> |
| | | a.end_time |
| | | </if> |
| | | , '%Y-%m' ) as time, |
| | | SUM(CASE |
| | | , '%Y-%m') as time, |
| | | (CASE |
| | | WHEN a.order_source = 0 THEN b.period_service_price |
| | | WHEN a.order_source = 1 THEN b.period_service_price |
| | | ELSE b.period_service_price * 0.8 |
| | | END) as servicecharge, |
| | | SUM(b.period_electric_price) as electrovalence, |
| | | SUM(b.charging_capacity) as electricity, |
| | | count(1) as orderCount |
| | | (b.period_electric_price) as electrovalence, |
| | | (b.charging_capacity) as electricity |
| | | FROM |
| | | t_charging_order a |
| | | left join (select charging_order_id, sum(period_electric_price) as period_electric_price, sum(period_service_price) as period_service_price, sum(charging_capacity) as charging_capacity, sum(period_electric_price + period_service_price) as money from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id) |
| | | WHERE a.del_flag = 0 and a.status = 5 and a.recharge_payment_status = 2 and DATE( |
| | | WHERE a.del_flag = 0 and a.status = 5 and a.recharge_payment_status = 2 and DATE_FORMAT( |
| | | <if test="statisticsQueryDto.type == 1"> |
| | | a.start_time |
| | | </if> |
| | | <if test="statisticsQueryDto.type == 2"> |
| | | a.end_time |
| | | </if> |
| | | ) between #{statisticsQueryDto.startTime} and #{statisticsQueryDto.endTime} |
| | | , '%Y-%m-%d') between #{statisticsQueryDto.startTime} and #{statisticsQueryDto.endTime} |
| | | <if test="siteIds != null and siteIds.size() > 0"> |
| | | and a.site_id IN |
| | | <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> |
| | | #{siteId} |
| | | </foreach> |
| | | </if> |
| | | GROUP BY |
| | | time |
| | | ORDER BY |
| | | time |
| | | |
| | | |
| | | ) as aa GROUP BY aa.time ORDER BY aa.time |
| | | </select> |
| | | <select id="getchargingCapacity" resultType="java.util.Map"> |
| | | SELECT |
| | |
| | | </foreach> |
| | | </if> |
| | | </select> |
| | | <select id="chargingOrderNolimit" resultType="com.ruoyi.order.api.vo.ChargingOrderVO"> |
| | | select t1.* |
| | | <select id="chargingOrderNolimit" resultType="map"> |
| | | select |
| | | sum(charging_capacity) as total, |
| | | sum(charging_duration) as `time`, |
| | | sum(electric_price) as electronicMoney, |
| | | sum(income) as paymentMoney, |
| | | sum(service_price) as serviceMoney |
| | | from t_charging_order_summary_data |
| | | where charging_order_id in ( |
| | | select t1.id |
| | | from t_charging_order t1 |
| | | where 1=1 |
| | | <if test="null != req.code and req.code!=''"> |
| | |
| | | and (t1.end_time between #{endTime1} and #{endTime2}) |
| | | </if> |
| | | and t1.del_flag = 0 |
| | | order by t1.create_time desc |
| | | ) |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.order.mapper.TChargingOrderSummaryDataMapper"> |
| | | |
| | | </mapper> |