装备租赁统计

This commit is contained in:
sxu 2024-12-31 13:20:07 +08:00
parent 9b007d4a0a
commit f2e848c0e4
8 changed files with 86 additions and 2 deletions

View File

@ -0,0 +1,18 @@
package com.bonus.common.biz.utils;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class MathUtil {
public static BigDecimal calculatePercentage(int num1, int num2) {
if (num2 == 0) {
throw new ArithmeticException("除数不能为0");
}
BigDecimal bdNum1 = new BigDecimal(num1);
BigDecimal bdNum2 = new BigDecimal(num2);
BigDecimal result = bdNum1.divide(bdNum2, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
return result.setScale(2, RoundingMode.HALF_UP);
}
}

View File

@ -266,4 +266,11 @@ public class DevInfo extends BaseEntity {
@ApiModelProperty(value = "租赁次数")
private Integer rentNum;
@ApiModelProperty(value = "累计上架天数")
private Integer totalUpDay;
@ApiModelProperty(value = "累计租赁天数")
private Integer totalLeaseDay;
}

View File

@ -198,8 +198,12 @@ public interface DevInfoMapper {
Integer getDevUpNum();
Integer getDevLeasingNum();
Integer getDevTypeNum();
Integer getDevQcWarningNum();
DevInfo getDevUsageRatio();
}

View File

@ -1,7 +1,9 @@
package com.bonus.material.largeScreen.controller;
import com.bonus.common.biz.domain.TypeInfo;
import com.bonus.common.biz.utils.MathUtil;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.device.domain.DevInfo;
import com.bonus.material.device.mapper.DevInfoMapper;
import com.bonus.material.largeScreen.entity.OrderData;
import com.bonus.material.largeScreen.entity.OrderDto;
@ -15,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* @Authorliang.chao
@ -83,4 +87,20 @@ public class LargeScreenController {
orderData.setDevQcWaningNum(devQcWarningNum);
return AjaxResult.success(orderData);
}
@ApiOperation("装备租赁统计")
@GetMapping("/devLeaseCount")
public AjaxResult devRentalCount() {
OrderDto orderDto = orderMapper.getOderCount();
OrderData orderData = new OrderData();
orderData.setOrderNum(orderDto.getOrderNum());
Integer devLeasingNum = devInfoMapper.getDevLeasingNum();
orderData.setDevLeasingNum(devLeasingNum);
DevInfo devInfo = devInfoMapper.getDevUsageRatio();
orderData.setDevUsageRatio(MathUtil.calculatePercentage(devInfo.getTotalLeaseDay(), devInfo.getTotalUpDay()));
return AjaxResult.success(orderData);
}
}

View File

@ -2,7 +2,6 @@ package com.bonus.material.largeScreen.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
@ -42,12 +41,18 @@ public class OrderData {
@ApiModelProperty(value = "装备总上架数")
private Integer devUpNum;
@ApiModelProperty(value = "装备总在租数")
private Integer devLeasingNum;
@ApiModelProperty(value = "装备总类型数")
private Integer devTypeNum;
@ApiModelProperty(value = "装备总报警数")
private Integer devQcWaningNum;
@ApiModelProperty(value = "订单总数")
private Integer orderNum;
@ApiModelProperty(value = "装备利用率")
private BigDecimal devUsageRatio;
}

View File

@ -62,4 +62,6 @@ public interface OrderMapper {
OrderData getCompanysCost();
OrderDto getTodayOderCount();
OrderDto getOderCount();
}

View File

@ -909,6 +909,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND ma_status = '2'
</select>
<select id="getDevLeasingNum" resultType="java.lang.Integer">
SELECT
COUNT(1)
FROM
ma_dev_info
WHERE
is_active = '1'
AND ma_status = '3'
</select>
<select id="getDevTypeNum" resultType="java.lang.Integer">
SELECT
count(distinct(type_id))
@ -928,4 +939,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
message_type = '3'
</select>
<select id="getDevUsageRatio" resultType="com.bonus.material.device.domain.DevInfo">
SELECT
sum(total_up_day) as totalUpDay,
sum(total_lease_day) as totalLeaseDay
FROM
bm_message
WHERE
message_type = '3'
</select>
</mapper>

View File

@ -431,6 +431,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
DATE_FORMAT( moi.create_time, '%Y-%m-%d' ) = DATE_FORMAT(NOW(),'%Y-%m-%d')
</select>
<select id="getOderCount" resultType="com.bonus.material.largeScreen.entity.OrderDto">
SELECT
count( moi.order_id ) orderNum,
ifnull(SUM( moi.cost ), 0) cost
FROM
ma_order_info moi
</select>
<delete id="deleteCostReliefs">
delete from ma_order_details_relief