Просмотр исходного кода

[电表][修改]:商户电表接口完善

release_toaliyun_real
hupeng 6 лет назад
Родитель
Сommit
4be76e9c6a
4 измененных файлов: 71 добавлений и 65 удалений
  1. +4
    -13
      mallinkService/src/main/java/com/iformall/domain/dto/KwMerchantMeterDto.java
  2. +15
    -2
      mallinkService/src/main/java/com/iformall/domain/vo/KwMerchantMeterVo.java
  3. +5
    -9
      mallinkService/src/main/java/com/iformall/service/impl/WxChartServiceImpl.java
  4. +47
    -41
      mallinkService/src/main/resources/mapper/KwMerchantMeterMapper.xml

+ 4
- 13
mallinkService/src/main/java/com/iformall/domain/dto/KwMerchantMeterDto.java Просмотреть файл

@@ -15,6 +15,7 @@ public class KwMerchantMeterDto extends BaseEntity {

private String tenantId;


@io.swagger.annotations.ApiModelProperty(value="商户名",name="name")
private String merchantName;

@@ -30,11 +31,9 @@ public class KwMerchantMeterDto extends BaseEntity {
@io.swagger.annotations.ApiModelProperty(value="子业态",name="subBusinessId")
private Integer subBusinessId;


@io.swagger.annotations.ApiModelProperty(value="状态0使用1作废",name="status")
@io.swagger.annotations.ApiModelProperty(value="状态1使用0停用",name="status")
private Integer status;


protected String sortColumns;

@Override
@@ -47,16 +46,8 @@ public class KwMerchantMeterDto extends BaseEntity {
private Long merchantId;

public static enum Field {
RecordStartTime_ASC("`recordStartTime` ASC"),
RecordStartTime_DESC("`recordStartTime` DESC"),
RecordEndTime_ASC("`recordEndTime` ASC"),
RecordEndTime_DESC("`recordEndTime` DESC"),
UsedPower_ASC("`usedPower` ASC"),
UsedPower_DESC("`usedPower` DESC"),
TotalEndTime_ASC("`totalPower` ASC"),
TotalEndTime_DESC("`totalPower` DESC"),
ReportTime_ASC("`reportTime` ASC"),
ReportTime_DESC("`reportTime` DESC");
BusinessId_ASC("`business_id` ASC"),
BusinessId_DESC("`business_id` DESC");
private String value;

Field(String value) {


+ 15
- 2
mallinkService/src/main/java/com/iformall/domain/vo/KwMerchantMeterVo.java Просмотреть файл

@@ -1,5 +1,6 @@
package com.iformall.domain.vo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.iformall.domain.po.KwMeter;
import lombok.Data;

@@ -9,9 +10,20 @@ import java.util.List;
/**
* @author gongbiao
*/
@JsonIgnoreProperties(value = {"handler"})
@Data
public class KwMerchantMeterVo {


@io.swagger.annotations.ApiModelProperty(value="商户ID",name="name")
private String id;

@io.swagger.annotations.ApiModelProperty(value="商户状态",name="name")
private String status;

@io.swagger.annotations.ApiModelProperty(value="租户ID",name="name")
private String tenantId;

@io.swagger.annotations.ApiModelProperty(value="商户名",name="name")
private String merchantName;

@@ -22,10 +34,11 @@ public class KwMerchantMeterVo {
private List<WxShopVo> shopVoList;

@io.swagger.annotations.ApiModelProperty(value = "电表列表", name = "meterList")
private Integer meterCount;
private List<KwMeter> meterList;


@io.swagger.annotations.ApiModelProperty(value = "电表列表", name = "meterList")
private List<KwMeter> meterList;
private Integer meterCount;

public Integer getMeterCount() {
if (meterList.isEmpty())


+ 5
- 9
mallinkService/src/main/java/com/iformall/service/impl/WxChartServiceImpl.java Просмотреть файл

@@ -406,7 +406,7 @@ public class WxChartServiceImpl implements WxChartDataService {
resultMap.put("lastUsedPower",lastMonthPower.getUsedPower());


if (lastMonthPower.getTotalPower() !=null && currentPower.getTotalPower() != null) {
if (lastMonthPower.getTotalPower() !=null && currentPower.getTotalPower() != null && lastMonthPower.getTotalPower() !=0) {
double hbd = (double) (currentPower.getTotalPower() - lastMonthPower.getTotalPower()) / lastMonthPower.getTotalPower() * 100;
double hb = new BigDecimal(hbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
resultMap.put("totalPowerRate", hb + "%");
@@ -414,14 +414,10 @@ public class WxChartServiceImpl implements WxChartDataService {
resultMap.put("totalPowerRate", "--" + "%");
}

if (lastMonthPower.getUsedPower() !=null && currentPower.getUsedPower() != null) {
if(lastMonthPower.getUsedPower().equals(0)){
resultMap.put("usedPowerRate", "0%");
}else{
double hbd = (double) (currentPower.getUsedPower() - lastMonthPower.getUsedPower()) / lastMonthPower.getUsedPower() * 100;
double hb = new BigDecimal(hbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
resultMap.put("usedPowerRate", hb + "%");
}
if (lastMonthPower.getUsedPower() !=null && currentPower.getUsedPower() != null && lastMonthPower.getUsedPower() !=0) {
double hbd = (double) (currentPower.getUsedPower() - lastMonthPower.getUsedPower()) / lastMonthPower.getUsedPower() * 100;
double hb = new BigDecimal(hbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
resultMap.put("usedPowerRate", hb + "%");
} else {
resultMap.put("usedPowerRate", "--" + "%");
}


+ 47
- 41
mallinkService/src/main/resources/mapper/KwMerchantMeterMapper.xml Просмотреть файл

@@ -56,15 +56,39 @@
<include refid="dynamicWhereConditions"/>
</select>

<resultMap id="MeterBaseResultMap" type="com.iformall.domain.po.KwMeter">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
<result column="address" jdbcType="BIGINT" property="address"/>
<result column="brand" jdbcType="VARCHAR" property="brand"/>
<result column="place" jdbcType="VARCHAR" property="place"/>
<result column="model" jdbcType="VARCHAR" property="model"/>
<result column="protocol" jdbcType="INTEGER" property="protocol"/>
<result column="bandrate" jdbcType="INTEGER" property="bandrate"/>
<result column="last_online_time" jdbcType="TIMESTAMP" property="lastOnlineTime"/>
<result column="online_status" jdbcType="INTEGER" property="onlineStatus"/>
<result column="config" jdbcType="VARCHAR" property="config"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="box_id" jdbcType="BIGINT" property="boxId"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="bind_status" jdbcType="INTEGER" property="bindStatus"/>
</resultMap>

<select id="findMeterList" parameterType="java.util.Map" resultMap="MeterBaseResultMap">
select m.* from kw_merchant_meter mm
left join kw_meter m on mm.`meter_id` = m.id
where mm.`status` = 0 and m.`bind_status` = 0
<if test=" null != merchantId ">
and mm.`merchant_id` = #{merchantId}
</if>
</select>


<resultMap id="BaseResultMapVo" type="com.iformall.domain.vo.KwMerchantMeterVo">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
<result column="meter_id" jdbcType="BIGINT" property="meterId"/>
<result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>

<result column="name" jdbcType="VARCHAR" property="merchantName"/>
<result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone"/>
@@ -75,55 +99,37 @@
select="com.iformall.mapper.WxShopMapper.findShopVoList">
</collection>

<collection column="{merchantId=id}" property="shopVoList"
ofType="com.iformall.domain.vo.WxShopVo"
<collection column="{merchantId=id}" property="meterList"
ofType="com.iformall.domain.po.kwMeter"
javaType="java.util.List"
select="com.iformall.mapper.WxShopMapper.findShopVoList">
select="com.iformall.mapper.KwMerchantMeterMapper.findMeterList">
</collection>

</resultMap>

<sql id="allColumnsVo">
`id`,`tenant_id`,`meter_id`,`merchant_id`,`status`,`create_time`,`update_time`, `name`, `link_phone`
`id`, `tenant_id`, `merchant_id`, `status`, `name`, `link_phone`
</sql>

<sql id="dynamicWhereConditionsVo">
where 1 = 1

<if test=" null != id ">
and `id` = #{id}
</if>

<if test=" null != tenantId ">
and `tenant_id` = #{tenantId}
</if>
<select id="findListVo" parameterType="com.iformall.domain.dto.KwMerchantMeterDto" resultMap="BaseResultMapVo">
select <include refid="allColumnsVo"/>
from (
select merchant_id from kw_merchant_meter
where `status` = 0

<if test=" null != merchantId ">
and `merchant_id` = #{merchantId}
</if>
<if test=" null != tenantId ">
and `tenant_id` = #{tenantId}
</if>

<if test=" null != meterId ">
and `meter_id` = #{meterId}
</if>
<if test=" null != merchantId ">
and `merchant_id` = #{merchantId}
</if>

<if test=" null != status ">
and `status` = #{status}
</if>
group by merchant_id
) temp
, wx_merchant
where temp.merchant_id = id

<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>
<if test=" null != sortColumns">order by ${sortColumns}</if>
</sql>

<select id="findListVo" parameterType="com.iformall.domain.dto.KwMerchantMeterDto" resultMap="BaseResultMap">
select
<include refid="allColumnsVo"/>
from kw_merchant_meter, wx_merchant
<include refid="dynamicWhereConditionsVo"/>
</select>

<update id="unbindBatch" parameterType="com.iformall.domain.po.KwMerchantMeter">


Загрузка…
Отмена
Сохранить