update 首页汇总数据更换查询表

This commit is contained in:
Lemon
2023-07-20 16:03:55 +08:00
parent a3aaef384e
commit d99faaad46
6 changed files with 70 additions and 21 deletions

View File

@@ -73,6 +73,7 @@ public class PersonPileController extends BaseController {
/**
* 用户解绑个人桩
* http://localhost:8080/uniapp/personalPile/userUnbindPile
* @return
*/
@RequestMapping("/userUnbindPile")

View File

@@ -137,6 +137,7 @@ public interface PileBasicInfoMapper {
*/
public IndexGeneralSituationVO getGeneralSituation(@Param("IndexQueryDTO")IndexQueryDTO dto);
public IndexGeneralSituationVO getGeneralSituationInfo(@Param("IndexQueryDTO")IndexQueryDTO dto);
/**
* 通过会员id查询个人桩列表

View File

@@ -23,6 +23,7 @@ import com.jsowell.pile.dto.IndexQueryDTO;
import com.jsowell.pile.dto.QueryPileDTO;
import com.jsowell.pile.dto.ReplaceMerchantStationDTO;
import com.jsowell.pile.mapper.PileBasicInfoMapper;
import com.jsowell.pile.mapper.PileMerchantInfoMapper;
import com.jsowell.pile.service.IPileBasicInfoService;
import com.jsowell.pile.service.IPileConnectorInfoService;
import com.jsowell.pile.service.IPileMerchantInfoService;
@@ -47,9 +48,7 @@ import org.springframework.util.StopWatch;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -83,6 +82,9 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
@Autowired
private SimCardService simCardService;
@Autowired
private PileMerchantInfoMapper pileMerchantInfoMapper;
@Autowired
private RedisCache redisCache;
@@ -600,18 +602,40 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
stationIdList.addAll(list);
}
}
if (CollectionUtils.isEmpty(stationDeptIds) && CollectionUtils.isEmpty(merchantDeptIds)) {
// 都为空说明为平台管理员
List<String> list = pileMerchantInfoService.queryByMerchantDeptIds(null);
// 对list去空
List<String> stationList = list.stream()
.filter(Objects::nonNull)
.collect(Collectors.toList());
stationIdList.addAll(stationList);
}
log.info("后管首页基本信息查询 authorizedMap:{}, dto:{}", JSONObject.toJSONString(authorizedMap), JSONObject.toJSONString(dto));
dto.setStationIdList(stationIdList);
IndexGeneralSituationVO generalSituation = pileBasicInfoMapper.getGeneralSituation(dto);
// IndexGeneralSituationVO generalSituation = pileBasicInfoMapper.getGeneralSituation(dto);
IndexGeneralSituationVO generalInfo = pileBasicInfoMapper.getGeneralSituationInfo(dto);
List<PileInfoVO> pileInfoVOS = queryPileDetailList(stationIdList);
// 对集合根据pileSn进行去重
ArrayList<PileInfoVO> pileInfoList = pileInfoVOS.stream()
.collect(Collectors.collectingAndThen(Collectors.toCollection(()
-> new TreeSet<>(Comparator.comparing(PileInfoVO::getPileSn))), ArrayList::new));
// 桩总数
generalInfo.setTotalPileQuantity(String.valueOf(pileInfoList.size()));
// 总充电订单数 3.0 --> 3
generalInfo.setTotalChargingQuantity(generalInfo.getTotalChargingQuantity().replaceAll("[.](.*)",""));
// 会员总余额
// demo账号
if (SecurityUtils.getUsername().equals("demo")) {
generalSituation.setTotalChargingAmount(new BigDecimal(generalSituation.getTotalChargingAmount()).multiply(new BigDecimal("20")).toString());
generalSituation.setTotalPileQuantity(new BigDecimal(generalSituation.getTotalPileQuantity()).multiply(new BigDecimal("20")).toString());
generalSituation.setTotalChargingDegree(new BigDecimal(generalSituation.getTotalChargingDegree()).multiply(new BigDecimal("20")).toString());
generalSituation.setTotalChargingQuantity(new BigDecimal(generalSituation.getTotalChargingQuantity()).multiply(new BigDecimal("20")).toString());
generalSituation.setTotalMemberAmount(new BigDecimal(generalSituation.getTotalMemberAmount()).multiply(new BigDecimal("20")).toString());
generalInfo.setTotalChargingAmount(new BigDecimal(generalInfo.getTotalChargingAmount()).multiply(new BigDecimal("20")).toString());
generalInfo.setTotalPileQuantity(new BigDecimal(generalInfo.getTotalPileQuantity()).multiply(new BigDecimal("20")).toString());
generalInfo.setTotalChargingDegree(new BigDecimal(generalInfo.getTotalChargingDegree()).multiply(new BigDecimal("20")).toString());
generalInfo.setTotalChargingQuantity(new BigDecimal(generalInfo.getTotalChargingQuantity()).multiply(new BigDecimal("20")).toString());
// generalInfo.setTotalMemberAmount(new BigDecimal(generalInfo.getTotalMemberAmount()).multiply(new BigDecimal("20")).toString());
}
return generalSituation;
return generalInfo;
}
/**

View File

@@ -408,4 +408,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item,jdbcType=BIGINT}
</foreach>
</update>
<select id="getGeneralSituationInfo" resultType="com.jsowell.pile.vo.web.IndexGeneralSituationVO">
select
sum(t1.total_amount) as totalChargingAmount,
sum(t1.use_electricity) as totalChargingDegree,
sum(t1.charge_num) as totalChargingQuantity
from
settle_order_report t1
where
t1.del_flag = '0'
<if test="IndexQueryDTO.stationId != null and IndexQueryDTO.stationId != ''">
and t1.station_id = #{IndexQueryDTO.stationId,jdbcType=VARCHAR}
</if>
<!-- 数据范围过滤 -->
<if test="IndexQueryDTO.stationIdList != null and IndexQueryDTO.stationIdList.size() != 0">
and t1.station_id in
<foreach collection="IndexQueryDTO.stationIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
</mapper>

View File

@@ -273,10 +273,12 @@
LEFT JOIN pile_station_info t2 ON t2.merchant_id = t1.id and t2.del_flag = '0'
WHERE
t1.del_flag = '0'
<if test="merchantDeptIds != null and merchantDeptIds.size() != 0">
AND t1.dept_id IN
<foreach collection="merchantDeptIds" item="item" open="(" separator="," close=")">
#{item,jdbcType=VARCHAR}
</foreach>
</if>
</select>
<select id="queryInfoByDeptId" resultMap="PileMerchantInfoResult">

View File

@@ -12,7 +12,7 @@
<div class="box-h1">{{ generalSituation.totalChargingDegree}}</div>
<div>总充电电量()</div>
</div>
</div>
<div class="box" style="background-color: #c74542;">
<el-image class="box-image"
@@ -40,16 +40,16 @@
<div>总充电设备数量()</div>
</div>
</div>
<div class="box" v-hasRole="['admin', 'common']" style="background-color: #ff4949;">
<el-image
class="box-image"
:src="require('@/assets/images/yue.png')"
></el-image>
<div class="flex1">
<div class="box-h1">{{ generalSituation.totalMemberAmount }}</div>
<div>总客户余额()</div>
</div>
</div>
<!-- <div class="box" v-hasRole="['admin', 'common']" style="background-color: #ff4949;">-->
<!-- <el-image-->
<!-- class="box-image"-->
<!-- :src="require('@/assets/images/yue.png')"-->
<!-- ></el-image>-->
<!-- <div class="flex1">-->
<!-- <div class="box-h1">{{ generalSituation.totalMemberAmount }}</div>-->
<!-- <div>总客户余额()</div>-->
<!-- </div>-->
<!-- </div>-->
</div>
<h1>订单</h1>