This commit is contained in:
马三炮 2025-09-15 23:21:46 +08:00
parent ac05148928
commit ec17584681
7 changed files with 213 additions and 22 deletions

View File

@ -303,5 +303,9 @@ public interface DevInfoMapper {
List<DevInfoVo> selectCheckDevInfoList(DevInfoVo devInfo);
Integer updateCheckStatus(List<MapBean> list);
Integer getTotalEquipmentByLevel(DevInfoReq devInfoReq);
int getTurnoverRateByLevel(DevInfoReq devInfoReq);
}

View File

@ -126,36 +126,80 @@ public class ProvinceScreenController extends BaseController {
public AjaxResult getEquipmentUse() {
try {
List<Map<String,Object>> res = provinceScreenService.getEquipmentUse();
for (int i = 0; i < 10; i++) {
Map<String,Object> map = new HashMap<>();
map.put("projectName","石桥-大陇π入万济变、大陇-阳湖T接万济变 35kV架空线路工程");
map.put("inUser","82");
map.put("scale","172");
map.put("usage","47.67");
res.add(map);
}
Map<String,Object> map = new HashMap<>();
map.put("projectName","石桥-大陇π入万济变、大陇-阳湖T接万济变 35kV架空线路工程");
map.put("inUser","82");
map.put("scale","172");
map.put("usage","47.67");
res.add(map);
map.put("projectName","淮南泥河110kV变电站新建工程");
map.put("inUser","66");
map.put("scale","170");
map.put("usage","48.67");
res.add(map);
map.put("projectName","安徽黄山市徽州区呈坎35kV变电站新建工程");
map.put("inUser","68");
map.put("scale","160");
map.put("usage","49.67");
res.add(map);
map.put("projectName","凌云220kV变电站新建工程");
map.put("inUser","65");
map.put("scale","175");
map.put("usage","45.67");
res.add(map);
map.put("projectName","东坡110kV变电站新建工程");
map.put("inUser","68");
map.put("scale","174");
map.put("usage","49.67");
res.add(map);
return AjaxResult.success(res);
} catch (Exception e) {
return AjaxResult.error("工程在用装备情况异常");
}
}
/**
* 装备在用率统计
* @return
*/
@ApiOperation("装备在用率统计")
@GetMapping("/getUsageStatistics")
public AjaxResult getUsageStatistics() {
public AjaxResult getUsageStatistics(Integer type) {
try {
List<Map<String,Object>> res = provinceScreenService.getUsageStatistics();
for (int i = 0; i < 10; i++) {
Map<String,Object> map = new HashMap<>();
map.put("projectName","石桥-大陇π入万济变、大陇-阳湖T接万济变 35kV架空线路工程");
map.put("inUser","82");
map.put("scale","172");
map.put("usage","47.67");
res.add(map);
}
List<Map<String,Object>> res = provinceScreenService.getUsageStatistics(type);
return AjaxResult.success(res);
} catch (Exception e) {
return AjaxResult.error("装备在用率统计异常");
}
}
/**
* 在库装备数
* @return
*/
@ApiOperation("在库装备数")
@GetMapping("/getEquipmentNumber")
public AjaxResult getEquipmentNumber() {
try {
List<Map<String,Object>> res = provinceScreenService.getEquipmentNumber();
return AjaxResult.success(res);
} catch (Exception e) {
return AjaxResult.error("在库装备数异常");
}
}
/**
* 机械化率
* @return
*/
@ApiOperation("机械化率")
@GetMapping("/getMechanizationRate")
public AjaxResult getMechanizationRate() {
try {
List<Map<String,Object>> res = provinceScreenService.getMechanizationRate();
return AjaxResult.success(res);
} catch (Exception e) {
return AjaxResult.error("在库装备数异常");
}
}
}

View File

@ -47,5 +47,17 @@ public interface ProvinceScreenService {
*/
List<Map<String, Object>> getEquipmentUse();
List<Map<String, Object>> getUsageStatistics();
/**
* 装备在用率统计
* @return
*/
List<Map<String, Object>> getUsageStatistics(Integer type);
/**
* 在库装备数
* @return
*/
List<Map<String, Object>> getEquipmentNumber();
List<Map<String, Object>> getMechanizationRate();
}

View File

@ -1,6 +1,7 @@
package com.bonus.material.largeScreen.service.impl;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.material.device.domain.DevInfo;
import com.bonus.material.device.mapper.DevInfoMapper;
import com.bonus.material.equipment.domain.DeptConfigRateSummary;
@ -9,6 +10,8 @@ import com.bonus.material.equipment.service.ISysDeptService;
import com.bonus.material.equipment.service.impl.SysDeptServiceImpl;
import com.bonus.material.largeScreen.entity.DevInfoReq;
import com.bonus.material.largeScreen.service.ProvinceScreenService;
import com.bonus.material.ma.mapper.MaTypeMapper;
import com.bonus.material.ma.vo.MaType;
import com.bonus.system.api.domain.SysDept;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -38,6 +41,9 @@ public class ProvinceScreenServiceImpl implements ProvinceScreenService {
@Resource
private ISysDeptService sysDeptService;
@Resource
private MaTypeMapper maTypeMapper;
/**
* 装备总量总价值
* @return
@ -282,8 +288,90 @@ public class ProvinceScreenServiceImpl implements ProvinceScreenService {
return res;
}
/**
* 装备在用率统计
* @return
*/
@Override
public List<Map<String, Object>> getUsageStatistics() {
public List<Map<String, Object>> getUsageStatistics(Integer type) {
List<Map<String, Object>> res = new ArrayList<>();
List<MaType> maTypeList = new ArrayList<>();
//获取装备在用率 查询全部
if (StringUtils.isNull(type)){
maTypeList = maTypeMapper.selectMaTypeTreeBy5Level(type);
}else {
maTypeList = maTypeMapper.selectMaTypeTreeBy5Level2(type);
}
if (maTypeList.size()>0){
for (MaType maType:maTypeList) {
Map<String, Object> dev = new HashMap<>();
DevInfoReq devInfoReq = new DevInfoReq();
devInfoReq.setTypeId(Math.toIntExact(maType.getTypeId()));
//装备总数
Integer sum = devInfoMapper.getTotalEquipmentByLevel(devInfoReq);
//自用2
devInfoReq.setChangeStatus("2");
Integer inUse = devInfoMapper.getTotalEquipmentByLevel(devInfoReq);
devInfoReq.setChangeStatus("3");
Integer share = devInfoMapper.getTotalEquipmentByLevel(devInfoReq);
inUse = inUse+share;
dev.put("name",maType.getTypeName());
//在用率
dev.put("proportion",sum > 0 ? (inUse * 100) / sum : 0+"%");
//周转率
int turnoverRate = devInfoMapper.getTurnoverRateByLevel(devInfoReq);
dev.put("turnoverRate",sum > 0 ? (turnoverRate * 100) / sum : 0+"次/年");
res.add(dev);
}
}
// 核心排序逻辑按proportion数值降序排序高在用率优先
Collections.sort(res, new Comparator<Map<String, Object>>() {
@Override
public int compare(Map<String, Object> map1, Map<String, Object> map2) {
// 1. 提取两个map中的proportion字符串
String proportion1 = (String) map1.get("proportion");
String proportion2 = (String) map2.get("proportion");
// 2. 处理null值默认视为0%
proportion1 = proportion1 == null ? "0%" : proportion1;
proportion2 = proportion2 == null ? "0%" : proportion2;
// 3. 去掉"%"符号转为Integer数值核心步骤
// 注意若proportion含小数"83.5%"需转为Double此处按整数处理适配原代码逻辑
int propValue1 = Integer.parseInt(proportion1.replace("%", ""));
int propValue2 = Integer.parseInt(proportion2.replace("%", ""));
// 4. 数值降序排序高在用率在前升序用propValue1 - propValue2
return propValue2 - propValue1;
}
});
return res;
}
/**
* 在库装备数
* @return
*/
@Override
public List<Map<String, Object>> getEquipmentNumber() {
//在库装备数
List<Map<String, Object>> res = new ArrayList<>();
SysDept sysDept = new SysDept();
List<SysDept> sysDeptList = sysDeptMapper.selectDeptList(sysDept);
for (SysDept sysDeptNew:sysDeptList) {
Map<String, Object> dept = new HashMap<>();
//入库1
DevInfoReq devInfoReq = new DevInfoReq();
devInfoReq.setOwnCo(Math.toIntExact(sysDeptNew.getDeptId()));
devInfoReq.setChangeStatus("1");
Integer inStock = devInfoMapper.getTotalEquipment(devInfoReq);
dept.put("name",sysDeptNew.getDeptName());
dept.put("num",inStock);
res.add(dept);
}
return res;
}
@Override
public List<Map<String, Object>> getMechanizationRate() {
return null;
}

View File

@ -96,4 +96,8 @@ public interface MaTypeMapper {
int insertMaTypePropertyNames(@Param("typeId") Long typeId, @Param("list") List<MaTypeProperty> properties);
List<MaType> getList(@Param("typeName") String typeName, @Param("level") Integer level);
}
List<MaType> selectMaTypeTreeBy5Level(Integer type);
List<MaType> selectMaTypeTreeBy5Level2(Integer type);
}

View File

@ -1572,4 +1572,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</update>
<select id="getTotalEquipmentByLevel" resultType="java.lang.Integer">
select count(1)
from ma_dev_info mdi
left join ma_type mt on mdi.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
left join ma_type mt2 on mt1.parent_id = mt2.type_id
where mt2.type_id = #{typeId} and mdi.is_active ='1'
<if test="changeStatus != null ">
AND change_status = #{changeStatus}
</if>
</select>
<select id="getTurnoverRateByLevel" resultType="java.lang.Integer">
select count(1) from cs_device_change_details cdcd
left join cs_device_change cdc on cdcd.change_id = cdc.id
left join ma_dev_info mdi on mdi.ma_id = cdcd.dev_id
left join ma_type mt on mdi.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
left join ma_type mt2 on mt1.parent_id = mt2.type_id
where cdcd.del_flag = '0'
AND cdc.create_time >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH)
<if test="typeId != null ">
AND mt2.type_id = #{typeId}
</if>
</select>
</mapper>

View File

@ -618,6 +618,21 @@
and m.type_name = #{typeName}
</if>
</select>
<select id="selectMaTypeTreeBy5Level" resultType="com.bonus.material.ma.vo.MaType">
select type_id, type_name from ma_type where del_flag = '0' and level = '5'
</select>
<select id="selectMaTypeTreeBy5Level2" resultType="com.bonus.material.ma.vo.MaType">
select mt.type_id, mt.type_name
from ma_type mt
left join ma_type mt1 on mt.parent_id = mt1.type_id
left join ma_type mt2 on mt1.parent_id = mt2.type_id
left join ma_type mt3 on mt2.parent_id = mt3.type_id
left join ma_type mt4 on mt3.parent_id = mt4.type_id
where mt.del_flag = '0'
<if test="type != null ">
AND mt4.type_id = #{type}
</if>
</select>
<delete id="deleteMaTypePropertyNames">
delete
@ -639,4 +654,4 @@
)
</foreach>
</insert>
</mapper>
</mapper>