效率利用分析

This commit is contained in:
方亮 2025-10-29 13:35:25 +08:00
parent 5388645137
commit 9bc741f1c1
4 changed files with 118 additions and 26 deletions

View File

@ -28,6 +28,55 @@ public class SjMaxDeviceController extends BaseController {
private SjMaxDeviceService service; private SjMaxDeviceService service;
/**
* 效率整体情况
*
* @param o 传参
* @return 资源应用利率控制层
*/
@GetMapping("selectDeviceWorkerEfficiency")
public AjaxResult selectDeviceWorkerEfficiency(SjMaxDevice o) {
try {
return service.selectDeviceWorkerEfficiency(o);
} catch (Exception e) {
log.error(e.toString(),e);
return error("请求出错了");
}
}
/**
* 效率分析top5
*
* @param o 传参
* @return 资源应用利率控制层
*/
@GetMapping("selectTeamEfficiencyEcharts")
public AjaxResult selectTeamEfficiencyEcharts(SjMaxDevice o) {
try {
return service.selectTeamEfficiencyEcharts(o);
} catch (Exception e) {
log.error(e.toString(),e);
return error("请求出错了");
}
}
/**
* 一周到岗人数趋势
*
* @param o 传参
* @return 资源应用利率控制层
*/
@GetMapping("selectWeekOnDutyEcharts")
public AjaxResult selectWeekOnDutyEcharts(SjMaxDevice o) {
try {
return service.selectWeekOnDutyEcharts(o);
} catch (Exception e) {
log.error(e.toString(),e);
return error("请求出错了");
}
}
/** /**
* 资源应用利率控制层 * 资源应用利率控制层
* *
@ -35,7 +84,7 @@ public class SjMaxDeviceController extends BaseController {
* @return 资源应用利率控制层 * @return 资源应用利率控制层
*/ */
@GetMapping("selectDeviceEcharts") @GetMapping("selectDeviceEcharts")
public AjaxResult selectDeviceEcharts(SjMaxDevice o) { public AjaxResult selectDeviceEcharts11(SjMaxDevice o) {
try { try {
return service.selectDeviceEcharts(o); return service.selectDeviceEcharts(o);
} catch (Exception e) { } catch (Exception e) {
@ -45,4 +94,6 @@ public class SjMaxDeviceController extends BaseController {
} }
} }

View File

@ -6,4 +6,10 @@ public interface SjMaxDeviceService{
AjaxResult selectDeviceEcharts(SjMaxDevice o); AjaxResult selectDeviceEcharts(SjMaxDevice o);
AjaxResult selectTeamEfficiencyEcharts(SjMaxDevice o);
AjaxResult selectWeekOnDutyEcharts(SjMaxDevice o);
AjaxResult selectDeviceWorkerEfficiency(SjMaxDevice o);
} }

View File

@ -24,10 +24,25 @@ public class SjMaxDeviceServiceImpl implements SjMaxDeviceService{
@Override @Override
public AjaxResult selectDeviceEcharts(SjMaxDevice o) { public AjaxResult selectDeviceEcharts(SjMaxDevice o) {
Map<String, Object> result = new HashMap<>();
//设备的图
List<SjMaxDevice> list = mapper.selectDeviceEcharts(o); List<SjMaxDevice> list = mapper.selectDeviceEcharts(o);
result.put("deviceEcharts", list); return AjaxResult.success("查询成功",list);
}
@Override
public AjaxResult selectTeamEfficiencyEcharts(SjMaxDevice o) {
//一周到岗率
LocalDate endDate = LocalDate.now(); // 今天
String endTime = endDate.toString();
o.setStartTime(endTime);
o.setEndTime(endTime);
//效率分析
List<SjMaxDevice> efficiencyList = mapper.selectEfficiency(o);
return AjaxResult.success("查询成功",efficiencyList);
}
@Override
public AjaxResult selectWeekOnDutyEcharts(SjMaxDevice o) {
Map<String, Object> result = new HashMap<>();
//一周到岗率 //一周到岗率
LocalDate endDate = LocalDate.now(); // 今天 LocalDate endDate = LocalDate.now(); // 今天
LocalDate startDate = endDate.minusDays(6); // 7天前 LocalDate startDate = endDate.minusDays(6); // 7天前
@ -36,22 +51,43 @@ public class SjMaxDeviceServiceImpl implements SjMaxDeviceService{
o.setStartTime(startTime); o.setStartTime(startTime);
o.setEndTime(endTime); o.setEndTime(endTime);
List<SjMaxDevice> workerList = mapper.selectWorkerEcharts(o); List<SjMaxDevice> workerList = mapper.selectWorkerEcharts(o);
result.put("workerEcharts", workerList); return AjaxResult.success("查询成功",workerList);
}
@Override
public AjaxResult selectDeviceWorkerEfficiency(SjMaxDevice o) {
Map<String, Object> result = new HashMap<>();
//设备的图
List<SjMaxDevice> list = mapper.selectDeviceEcharts(o);
//一周到岗率
LocalDate endDate = LocalDate.now(); // 今天
LocalDate startDate = endDate.minusDays(6); // 6天前
String startTime = startDate.toString(); // 格式yyyy-MM-dd
String endTime = endDate.toString();
o.setStartTime(startTime);
o.setEndTime(endTime);
List<SjMaxDevice> workerList = mapper.selectWorkerEcharts(o);
result.put("todayDutyRate", 0); result.put("todayDutyRate", 0);
result.put("yesterdayDutyRate", 0); result.put("yesterdayDutyRate", 0);
if(workerList != null && !workerList.isEmpty()){ if(workerList != null && !workerList.isEmpty()){
result.put("todayDutyRate", workerList.get(workerList.size()-1).getActualCount()/workerList.get(workerList.size()-1).getShouldCount()*100); result.put("todayDutyRate", Math.round(workerList.get(workerList.size()-1).getActualCount()*100/Double.valueOf(workerList.get(workerList.size()-1).getShouldCount()) * 10.0) / 10.0);
if(workerList.size()>1){ if(workerList.size()>1){
result.put("yesterdayDutyRate", workerList.get(workerList.size()-2).getActualCount()/workerList.get(workerList.size()-2).getShouldCount()*100); result.put("yesterdayDutyRate", Math.round(workerList.get(workerList.size()-2).getActualCount()*100/Double.valueOf(workerList.get(workerList.size()-2).getShouldCount()) * 10.0) / 10.0);
} }
} }
//整体人员利用率和设备使用率 //整体人员利用率和设备使用率
double totalActualCount = workerList.stream() double totalActualCount = 0;
if (workerList != null) {
totalActualCount = workerList.stream()
.mapToDouble(SjMaxDevice::getActualCount) .mapToDouble(SjMaxDevice::getActualCount)
.sum(); .sum();
double totalShouldCount = workerList.stream() }
double totalShouldCount = 0;
if (workerList != null) {
totalShouldCount = workerList.stream()
.mapToDouble(SjMaxDevice::getShouldCount) .mapToDouble(SjMaxDevice::getShouldCount)
.sum(); .sum();
}
double workerUtilization = 0; double workerUtilization = 0;
if (totalShouldCount > 0) { if (totalShouldCount > 0) {
workerUtilization = (totalActualCount / totalShouldCount) * 100; workerUtilization = (totalActualCount / totalShouldCount) * 100;
@ -70,9 +106,6 @@ public class SjMaxDeviceServiceImpl implements SjMaxDeviceService{
deviceUtilization = (double) Math.round(deviceUtilization * 10.0) / 10.0; deviceUtilization = (double) Math.round(deviceUtilization * 10.0) / 10.0;
} }
result.put("deviceUtilization", deviceUtilization); result.put("deviceUtilization", deviceUtilization);
//效率分析
List<SjMaxDevice> efficiencyList = mapper.selectEfficiency(o);
result.put("efficiency", efficiencyList);
return AjaxResult.success("查询成功",result); return AjaxResult.success("查询成功",result);
} }
} }

View File

@ -85,19 +85,20 @@
wt.team_name, wt.team_name,
wt.team_leader, wt.team_leader,
tp_count.total_people, tp_count.total_people,
ROUND( IFNULL(ROUND(
COALESCE(SUM(actual.actual_count), 0) * 100.0 / COALESCE(SUM(actual.actual_count), 0) * 100.0 /
((DATEDIFF(#{endTime} , #{startTime}) + 1) * tp_count.total_people), ((DATEDIFF(#{endTime} , #{startTime}) + 1) * tp_count.total_people),
2 2
) AS utilization_rate -- 百分比形式(如 86.70 ),0.0) AS utilization_rate
FROM sj_work_team wt FROM sj_work_team wt
INNER JOIN ( Left JOIN (
-- 每个班组的总人数 -- 每个班组的总人数
SELECT SELECT
team_id, st.id as team_id,
COUNT(*) AS total_people COUNT(team_id) AS total_people
FROM sj_team_people FROM
WHERE team_id IS NOT NULL sj_work_team st
left join sj_team_people sp on st.id = sp.team_id
GROUP BY team_id GROUP BY team_id
) tp_count ON wt.id = tp_count.team_id ) tp_count ON wt.id = tp_count.team_id
CROSS JOIN ( CROSS JOIN (
@ -129,5 +130,6 @@
GROUP BY GROUP BY
wt.id, wt.team_name, wt.team_leader, tp_count.total_people wt.id, wt.team_name, wt.team_leader, tp_count.total_people
ORDER BY utilization_rate DESC ORDER BY utilization_rate DESC
limit 5
</select> </select>
</mapper> </mapper>