问题修复
This commit is contained in:
parent
ef8fd59d8b
commit
b63bde9f57
|
|
@ -20,7 +20,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 设备信息对象 ma_dev_info
|
||||
*
|
||||
*
|
||||
* @author syruan
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
|
@ -290,4 +290,13 @@ public class DevInfo extends BaseEntity {
|
|||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date nextCheckDate;
|
||||
|
||||
@ApiModelProperty(value = "使用率大于80")
|
||||
private Integer idle80;
|
||||
|
||||
@ApiModelProperty(value = "使用率大于30小于80")
|
||||
private Integer idle3080;
|
||||
|
||||
@ApiModelProperty(value = "使用率小于30")
|
||||
private Integer idle30;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,13 +17,13 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 设备信息Mapper接口
|
||||
*
|
||||
*
|
||||
* @author syruan
|
||||
*/
|
||||
public interface DevInfoMapper {
|
||||
/**
|
||||
* 查询设备信息
|
||||
*
|
||||
*
|
||||
* @param maId 设备信息主键
|
||||
* @return 设备信息
|
||||
*/
|
||||
|
|
@ -61,7 +61,7 @@ public interface DevInfoMapper {
|
|||
|
||||
/**
|
||||
* 查询设备信息列表
|
||||
*
|
||||
*
|
||||
* @param devInfo 设备信息
|
||||
* @return 设备信息集合
|
||||
*/
|
||||
|
|
@ -73,7 +73,7 @@ public interface DevInfoMapper {
|
|||
|
||||
/**
|
||||
* 新增设备信息
|
||||
*
|
||||
*
|
||||
* @param devInfo 设备信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -87,7 +87,7 @@ public interface DevInfoMapper {
|
|||
|
||||
/**
|
||||
* 修改设备信息
|
||||
*
|
||||
*
|
||||
* @param devInfo 设备信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -95,7 +95,7 @@ public interface DevInfoMapper {
|
|||
|
||||
/**
|
||||
* 删除设备信息 -- 逻辑删除 -- 限制状态删除
|
||||
*
|
||||
*
|
||||
* @param maId 设备信息主键
|
||||
* @param statusCode 状态码
|
||||
* @return 结果
|
||||
|
|
@ -104,7 +104,7 @@ public interface DevInfoMapper {
|
|||
|
||||
/**
|
||||
* 批量删除设备信息
|
||||
*
|
||||
*
|
||||
* @param maIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -242,5 +242,8 @@ public interface DevInfoMapper {
|
|||
*/
|
||||
List<DevInfoVo> getCompanyNum();
|
||||
|
||||
List<DevInfoVo> selectDevInfoHotListRatio(DevInfoVo devInfoVo);
|
||||
|
||||
List<DevInfoVo> getOrderByCompanyId(int companyId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.bonus.material.device.mapper.DevInfoMapper;
|
|||
import com.bonus.material.device.service.DevInfoService;
|
||||
import com.bonus.material.largeScreen.entity.OrderData;
|
||||
import com.bonus.material.largeScreen.entity.OrderDto;
|
||||
import com.bonus.material.largeScreen.service.LargeScreenService;
|
||||
import com.bonus.material.lease.domain.MaLeaseInfo;
|
||||
import com.bonus.material.lease.mapper.MaLeaseInfoMapper;
|
||||
import com.bonus.material.order.domain.OrderDetailDto;
|
||||
|
|
@ -49,11 +50,18 @@ public class LargeScreenController {
|
|||
@Resource
|
||||
private MaLeaseInfoMapper leaseInfoMapper;
|
||||
|
||||
@Resource
|
||||
private LargeScreenService largeScreenService;
|
||||
|
||||
@ApiOperation("闲置装备分析")
|
||||
@GetMapping("/getIdleDevRatio")
|
||||
public AjaxResult getIdleDevRatio() {
|
||||
List<DevInfo> list = devInfoMapper.getIdleDevRatio();
|
||||
return AjaxResult.success(list);
|
||||
try {
|
||||
DevInfo list = largeScreenService.getIdleDevRatio();
|
||||
return AjaxResult.success(list);
|
||||
}catch (Exception e){
|
||||
return AjaxResult.error("闲置装备分析异常");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("出租装备分析")
|
||||
|
|
@ -127,10 +135,10 @@ public class LargeScreenController {
|
|||
OrderData orderData = new OrderData();
|
||||
Integer leaseNum = leaseInfoMapper.getLeaseCount();
|
||||
Integer leaseOrderNum = leaseInfoMapper.getLeaseOrderCount();
|
||||
//Integer maTypeCountFromLease = leaseInfoMapper.getMaTypeCountFromLease();
|
||||
Integer maTypeCountFromLease = leaseInfoMapper.getMaTypeCountFromLease();
|
||||
String topPopularTypeName = leaseInfoMapper.getTopPopularTypeName();
|
||||
orderData.setLeaseNum(leaseNum);
|
||||
//orderData.setMaTypeCountFromLease(maTypeCountFromLease);
|
||||
orderData.setMaTypeCountFromLease(maTypeCountFromLease);
|
||||
orderData.setLeaseOrderRatio(MathUtil.calculatePercentage(leaseOrderNum, leaseNum));
|
||||
orderData.setTopPopularTypeName(topPopularTypeName);
|
||||
return AjaxResult.success(orderData);
|
||||
|
|
@ -187,6 +195,36 @@ public class LargeScreenController {
|
|||
return AjaxResult.success(companyList);
|
||||
}
|
||||
|
||||
/* @ApiOperation("租赁装备数及订单数")
|
||||
@GetMapping("/getCompanyNum")
|
||||
public AjaxResult getCompanyNum(int companyId) {
|
||||
// 查询装备对应订单数
|
||||
List<DevInfoVo> list = devInfoMapper.getOrderByCompanyId(companyId);
|
||||
// 查询装备对应所属公司
|
||||
List<DevInfoVo> companyList = devInfoMapper.getCompanyList();
|
||||
// 使用 Map 存储每个公司 ID 对应的订单总数
|
||||
Map<String, Integer> orderNumMap = new HashMap<>();
|
||||
for (DevInfoVo devInfoVo : list) {
|
||||
String companyId = devInfoVo.getCompanyId();
|
||||
// 如果 Map 中已经存在该公司 ID,则累加订单数;否则,将当前订单数作为初始值
|
||||
orderNumMap.put(companyId, orderNumMap.getOrDefault(companyId, 0) + devInfoVo.getOrderNum());
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(companyList)) {
|
||||
for (DevInfoVo infoVo : companyList) {
|
||||
String companyId = infoVo.getCompanyId();
|
||||
// 从 Map 中获取该公司 ID 对应的订单总数
|
||||
Integer orderNum = orderNumMap.getOrDefault(companyId, 0);
|
||||
infoVo.setOrderNum(orderNum);
|
||||
}
|
||||
// 根据 orderNum 降序排序,并取前 9 个元素
|
||||
companyList = companyList.stream()
|
||||
.sorted((vo1, vo2) -> Integer.compare(vo2.getOrderNum(), vo1.getOrderNum()))
|
||||
.limit(9)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return AjaxResult.success(companyList);
|
||||
}*/
|
||||
|
||||
// @ApiOperation("订单数据")
|
||||
// @GetMapping("/orderData")
|
||||
// public AjaxResult getOrderData() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
package com.bonus.material.largeScreen.service;
|
||||
|
||||
import com.bonus.material.device.domain.DevInfo;
|
||||
import com.bonus.material.device.domain.vo.DevInfoVo;
|
||||
|
||||
import java.rmi.ServerException;
|
||||
import java.util.List;
|
||||
|
||||
public interface LargeScreenService {
|
||||
DevInfo getIdleDevRatio() throws ServerException;
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package com.bonus.material.largeScreen.service.impl;
|
||||
|
||||
import com.bonus.common.biz.utils.MathUtil;
|
||||
import com.bonus.material.device.domain.DevInfo;
|
||||
import com.bonus.material.device.domain.vo.DevInfoVo;
|
||||
import com.bonus.material.device.mapper.DevInfoMapper;
|
||||
import com.bonus.material.largeScreen.service.LargeScreenService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.implementation.bytecode.Throw;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.rmi.ServerException;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class LargeScreenServiceImpl implements LargeScreenService {
|
||||
|
||||
@Resource
|
||||
private DevInfoMapper devInfoMapper;
|
||||
@Override
|
||||
public DevInfo getIdleDevRatio() throws ServerException {
|
||||
DevInfoVo devInfoVo = new DevInfoVo();
|
||||
DevInfo devInfo = new DevInfo();
|
||||
try {
|
||||
//获取所有设备信息
|
||||
List<DevInfoVo>devInfoList = devInfoMapper.selectDevInfoHotListRatio(devInfoVo);
|
||||
//计算使用率
|
||||
int idle80 = 0;
|
||||
int idle3080 = 0;
|
||||
int idle30 = 0;
|
||||
for (DevInfoVo devInfoVoNew:devInfoList) {
|
||||
if (devInfoVoNew.getTotalUpDay()==null){
|
||||
idle30++;
|
||||
continue;
|
||||
}
|
||||
if (devInfoVoNew.getTotalLeaseDay()==null){
|
||||
devInfoVoNew.setTotalLeaseDay(0);
|
||||
}
|
||||
log.info("============{}",devInfoVoNew.getMaId());
|
||||
BigDecimal result = MathUtil.calculatePercentage(devInfoVoNew.getTotalUpDay(), devInfoVoNew.getTotalUpDay() + devInfoVoNew.getTotalLeaseDay());
|
||||
int re1 = result.compareTo(new BigDecimal(80));
|
||||
int re2 = result.compareTo(new BigDecimal(30));
|
||||
//使用率>80
|
||||
if (re1>0){
|
||||
idle80++;
|
||||
//30<=使用率<=80
|
||||
}if (re1<=0 && re2>=0){
|
||||
idle3080++;
|
||||
//使用率<30
|
||||
}if (re2<0){
|
||||
idle30++;
|
||||
}
|
||||
}
|
||||
devInfo.setIdle30(idle30);
|
||||
devInfo.setIdle3080(idle3080);
|
||||
devInfo.setIdle80(idle80);
|
||||
}catch (Exception e){
|
||||
log.info("获取利用率失败{}",e.getMessage());
|
||||
throw new ServerException("获取利用率失败");
|
||||
}
|
||||
return devInfo;
|
||||
}
|
||||
}
|
||||
|
|
@ -983,11 +983,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="getDevQcWarningNum" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
COUNT(1)
|
||||
FROM
|
||||
bm_message
|
||||
WHERE
|
||||
message_type = '3'
|
||||
ma_dev_qc mdc
|
||||
left join ma_dev_info mdi on mdi.ma_id = mdc.ma_id
|
||||
left join sys_dept sd on mdc.qc_com = sd.dept_id
|
||||
where mdc.next_check_time < now()
|
||||
</select>
|
||||
|
||||
<select id="getDevUsageRatio" resultType="com.bonus.material.device.domain.DevInfo">
|
||||
|
|
@ -1130,4 +1131,65 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
GROUP BY
|
||||
md.ma_id
|
||||
</select>
|
||||
<select id="selectDevInfoHotListRatio" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
|
||||
SELECT
|
||||
d.ma_id as maId,
|
||||
d.code as code,
|
||||
d.identify_code as identifyCode,
|
||||
d.device_name as deviceName,
|
||||
d.device_count as deviceCount,
|
||||
d.device_weight as deviceWeight,
|
||||
d.type_id as typeId,
|
||||
mt4.type_name as typeName,
|
||||
d.ma_status as maStatus,
|
||||
d.brand as brand,
|
||||
d.model_name as modelName,
|
||||
d.production_date as productionDate,
|
||||
d.working_hours as workingHours,
|
||||
d.serial_number as serialNumber,
|
||||
mt4.lease_price as dayLeasePrice,
|
||||
d.person as person,
|
||||
d.person_phone as personPhone,
|
||||
d.own_co as companyId,
|
||||
d.total_lease_day as totalLeaseDay,
|
||||
d.total_up_day as totalUpDay,
|
||||
sd.dept_name as companyName,
|
||||
c.operate_address as operateAddress,
|
||||
d.create_time as createTime,
|
||||
mt3.type_id as thirdId,
|
||||
mt3.type_name as thirdName,
|
||||
mt2.type_id as secondId,
|
||||
mt2.type_name as secondName,
|
||||
mt1.type_id as firstId,
|
||||
mt1.type_name as firstName
|
||||
FROM
|
||||
ma_dev_info d
|
||||
LEFT JOIN sys_dept sd ON d.own_co = sd.dept_id
|
||||
LEFT JOIN bm_company_info c ON sd.dept_id = c.company_id
|
||||
LEFT JOIN ma_type mt4 ON mt4.type_id = d.type_id and mt4.del_flag = '0'
|
||||
LEFT JOIN ma_type mt3 ON mt3.type_id = mt4.parent_id and mt3.del_flag = '0'
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt3.parent_id and mt2.del_flag = '0'
|
||||
LEFT JOIN ma_type mt1 ON mt1.type_id = mt2.parent_id and mt1.del_flag = '0'
|
||||
where
|
||||
d.is_active='1'
|
||||
and d.ma_status In (1,2,3)
|
||||
<if test="deviceName != null and deviceName != ''">
|
||||
and d.device_name like concat('%',#{deviceName},'%')
|
||||
</if>
|
||||
order by d.create_time desc
|
||||
</select>
|
||||
<select id="getOrderByCompanyId" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
|
||||
SELECT
|
||||
md.ma_id AS maId,
|
||||
COUNT( md.order_id ) AS orderNum ,
|
||||
mdi.own_co AS companyId,
|
||||
md.order_id AS orderCode
|
||||
FROM
|
||||
ma_order_details md
|
||||
LEFT JOIN ma_dev_info mdi on md.ma_id = mdi.ma_id
|
||||
WHERE md.order_status != 0 and md.order_status != 99 and mdi.own_co =#{companyId}
|
||||
GROUP BY
|
||||
md.order_id
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -476,7 +476,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="getMaTypeCountFromLease" resultType="Integer">
|
||||
SELECT distinct(type_id)
|
||||
SELECT COUNT(DISTINCT(type_id))
|
||||
FROM ma_lease_details
|
||||
where type_id is not null
|
||||
</select>
|
||||
|
|
@ -538,4 +538,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
ORDER BY
|
||||
lease_count DESC
|
||||
</select>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue