省侧大屏接口

This commit is contained in:
cwchen 2024-03-28 15:18:49 +08:00
parent 41ef871f46
commit c16ba37ecf
10 changed files with 297 additions and 9 deletions

View File

@ -14,4 +14,10 @@ public class ScreenParamDto extends ScreenDto{
@ApiModelProperty("参数")
private String param;
@ApiModelProperty("开始时间")
private String startTime;
@ApiModelProperty("结束时间")
private String endTime;
}

View File

@ -5,7 +5,6 @@ import com.securitycontrol.entity.screen.dto.ScreenParamDto;
import com.securitycontrol.screen.service.IScIndexService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -59,4 +58,22 @@ public class ScIndexController {
public AjaxResult deviceStatus(ScreenParamDto dto){
return service.deviceStatus(dto);
}
@ApiOperation(value = "工程安全隐患分析")
@GetMapping("potentialSafetyHazard")
public AjaxResult potentialSafetyHazard(ScreenParamDto dto){
return service.potentialSafetyHazard(dto);
}
@ApiOperation(value = "资源利用")
@GetMapping("resourceUse")
public AjaxResult resourceUse(ScreenParamDto dto){
return service.resourceUse(dto);
}
@ApiOperation(value = "效率分析")
@GetMapping("efficiencyAnalysis")
public AjaxResult efficiencyAnalysis(ScreenParamDto dto){
return service.efficiencyAnalysis(dto);
}
}

View File

@ -77,6 +77,7 @@ public interface IScIndexMapper {
/**
* 设备状态
*
* @param dto
* @return List<Map < Object>>
* @description
@ -85,4 +86,50 @@ public interface IScIndexMapper {
*/
@MapKey("bidCode")
List<Map<String, Object>> deviceStatus(ScreenParamDto dto);
/**
* 工程安全隐患分析
*
* @param dto
* @return List<Map < Object>>
* @description
* @author cwchen
* @date 2024/3/28 9:13
*/
@MapKey("orgId")
List<Map<String, Object>> potentialSafetyHazard(ScreenParamDto dto);
/**
* 获取班组人员/获取站班会人员
*
* @param dto
* @return List<Integer>
* @description
* @author cwchen
* @date 2024/3/28 11:05
*/
List<Integer> getPersonnel(ScreenParamDto dto);
/**
* 设备 在线/不在线 数量
*
* @param dto
* @return List<Map < Object>>
* @description
* @author cwchen
* @date 2024/3/28 11:28
*/
@MapKey("id")
List<Map<String, Object>> allDeviceStatus(ScreenParamDto dto);
/**
* 效率分析工程进度分析
* @param dto
* @return List<Map < Object>>
* @description
* @author cwchen
* @date 2024/3/28 13:47
*/
@MapKey("id")
List<Map<String, Object>> efficiencyAnalysis(ScreenParamDto dto);
}

View File

@ -67,6 +67,7 @@ public interface IScIndexService {
/**
* 设备状态
*
* @param dto
* @return AjaxResult
* @description
@ -74,4 +75,36 @@ public interface IScIndexService {
* @date 2024/3/27 19:50
*/
AjaxResult deviceStatus(ScreenParamDto dto);
/**
* 工程安全隐患分析
*
* @param dto
* @return AjaxResult
* @description
* @author cwchen
* @date 2024/3/27 20:49
*/
AjaxResult potentialSafetyHazard(ScreenParamDto dto);
/**
* 资源利用
*
* @param dto
* @return AjaxResult
* @description
* @author cwchen
* @date 2024/3/28 10:51
*/
AjaxResult resourceUse(ScreenParamDto dto);
/**
* 效率分析(工程进度)
* @param dto
* @return AjaxResult
* @description
* @author cwchen
* @date 2024/3/28 13:39
*/
AjaxResult efficiencyAnalysis(ScreenParamDto dto);
}

View File

@ -1,6 +1,8 @@
package com.securitycontrol.screen.service.impl;
import com.securitycontrol.common.core.constant.Constant;
import com.securitycontrol.common.core.utils.StringUtils;
import com.securitycontrol.common.core.utils.aes.DateTimeHelper;
import com.securitycontrol.common.core.web.domain.AjaxResult;
import com.securitycontrol.entity.screen.dto.ScreenParamDto;
import com.securitycontrol.entity.screen.vo.ConstrQuality;
@ -10,11 +12,13 @@ import com.securitycontrol.screen.service.IScIndexService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
/**
@ -30,6 +34,9 @@ public class ScIndexServiceImpl implements IScIndexService {
@Resource(name = "IScIndexMapper")
private IScIndexMapper mapper;
@Resource(name = "testTaskExecutor")
private ThreadPoolTaskExecutor testTaskExecutor;
@Override
public AjaxResult proStatusStatistics(ScreenParamDto dto) {
Map<Object, Object> dataMap = new HashMap<>(16);
@ -153,9 +160,9 @@ public class ScIndexServiceImpl implements IScIndexService {
@Override
public AjaxResult deviceStatus(ScreenParamDto dto) {
HashMap<Object, Object> returnMap = new HashMap<>();
Map<Object, Object> returnMap = new HashMap<>(16);
List<Map<String, Object>> dataList = new ArrayList<>(256);
List<Map<String, Object>> list = new ArrayList<>(256);
List<Map<String, Object>> list = new ArrayList<>();
int allTotalNum = 0, onlineTotalNum = 0, offTotalNum = 0;
try {
list = mapper.deviceStatus(dto);
@ -194,4 +201,99 @@ public class ScIndexServiceImpl implements IScIndexService {
returnMap.put("offTotalNum", offTotalNum);
return AjaxResult.success(returnMap);
}
@Override
public AjaxResult potentialSafetyHazard(ScreenParamDto dto) {
List<Map<String, Object>> list = new ArrayList<>(16);
try {
String currentWeekTime = DateTimeHelper.getCurrentWeekTime();
String[] timeArr = currentWeekTime.split(",");
dto.setStartTime(timeArr[0]);
dto.setEndTime(timeArr[1]);
list = mapper.potentialSafetyHazard(dto);
} catch (Exception e) {
log.error("工程安全隐患分析", e);
}
return AjaxResult.success(list);
}
@Override
public AjaxResult resourceUse(ScreenParamDto dto) {
Map<String, Object> map = new HashMap<>(3);
// 人员利用率 设备使用率 能源使用情况
Double personnelRate = new Double(0),deviceRate = new Double(0),energyValue = new Double(1201);
try {
Future<Double> future = testTaskExecutor.submit(() -> {
log.info("人员利用率-执行线程{}", Thread.currentThread().getName());
List<Integer> personnelList = personnelList = mapper.getPersonnel(dto);
if(personnelList.get(0) == 0 || personnelList.get(1) == 0){
return new Double(0);
}
BigDecimal value = new BigDecimal("0");
BigDecimal multipleValue = new BigDecimal("100");
BigDecimal classPeople = BigDecimal.valueOf(personnelList.get(0));
BigDecimal teamPeople = BigDecimal.valueOf(personnelList.get(1));
value = classPeople.divide(teamPeople, 3, BigDecimal.ROUND_HALF_UP);
value = value.multiply(multipleValue);
return value.doubleValue();
});
Future<Double> future2 = testTaskExecutor.submit(() -> {
log.info("设备使用率-执行线程{}", Thread.currentThread().getName());
List<Map<String, Object>> list = new ArrayList<>();
list = mapper.allDeviceStatus(dto);
if(CollectionUtils.isEmpty(list)){
return new Double(0);
}
int onlineNum = 0,totalNum = list.size();
for (Map<String, Object> objectMap : list) {
if(Objects.equals(objectMap.get("status"),Constant.ONLINE)){
onlineNum ++;
}
}
BigDecimal onlineValue = BigDecimal.valueOf(onlineNum);
BigDecimal totalValue = BigDecimal.valueOf(totalNum);
return onlineValue.divide(totalValue, 3, BigDecimal.ROUND_HALF_UP).doubleValue();
});
personnelRate = future.get();
deviceRate = future2.get();
} catch (Exception e) {
log.error("资源利用", e);
}
map.put("personnelRate",personnelRate);
map.put("deviceRate",deviceRate);
map.put("energyValue",energyValue);
return AjaxResult.success(map);
}
@Override
public AjaxResult efficiencyAnalysis(ScreenParamDto dto) {
List<Map<String, Object>> dataList = new ArrayList<>();
List<Map<String, Object>> list = new ArrayList<>();
try {
list = mapper.efficiencyAnalysis(dto);
Map<String, List<Map<String, Object>>> map = list.stream().collect(Collectors.groupingBy(item -> {
return String.valueOf(item.get("bidCode"));
}));
map.forEach((k, v) -> {
// 根据每个工程的工序计划及进度填报计算效率
Map<String, Object> dataMap = new HashMap<>();
BigDecimal value = new BigDecimal("0");
BigDecimal multipleValue = new BigDecimal("100");
for (int i = 0; i < v.size(); i++) {
if(Objects.nonNull(v.get(i).get("planId")) && Objects.nonNull(v.get(i).get("gxProgress")) && Objects.nonNull(v.get(i).get("gxWeight"))){
BigDecimal bigDecimal = new BigDecimal(String.valueOf(v.get(i).get("gxWeight")));
BigDecimal bigDecimal2 = new BigDecimal(String.valueOf(v.get(i).get("gxProgress")));
value = value.add(bigDecimal.multiply(bigDecimal2).divide(multipleValue, 3, BigDecimal.ROUND_HALF_UP));
}
}
dataMap.put("proName",v.get(0).get("proName"));
dataMap.put("value",value.doubleValue());
dataList.add(dataMap);
});
} catch (Exception e) {
log.error("效率分析(工程进度分析)",e);
}
return AjaxResult.success(dataList);
}
}

View File

@ -79,4 +79,56 @@
INNER JOIN tb_project tp on tpb.bid_code = tp.bid_code AND tp.del_flag = 0
WHERE tbd.del_flage = 0
</select>
<!--工程安全隐患分析-->
<select id="potentialSafetyHazard" resultType="java.util.Map">
SELECT sb.org_id AS orgId,
sb.city_name AS orgName,
IFNULL(a.num,0) AS planNum,
0 AS dangerNum
FROM sys_build sb
LEFT JOIN (
SELECT build_no,COUNT(build_no) AS num
FROM jj_week_plan
WHERE start_date BETWEEN #{startTime} AND #{endTime} AND end_date BETWEEN #{startTime} AND #{endTime}
GROUP BY build_no
)a ON sb.org_id = a.build_no
</select>
<!--取班组人员/获取站班会人员-->
<select id="getPersonnel" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM t_class_metting_people
WHERE create_day = CURRENT_DATE
UNION ALL
SELECT COUNT(*)
FROM t_team_people
WHERE del_falge = '0'
</select>
<!--设备 在线/不在线 数量 边带子设备/设备-->
<select id="allDeviceStatus" resultType="java.util.Map">
SELECT tbd.device_id AS id, IF(tbd.status = '801', '1', '0') AS status
FROM tb_bd_device tbd
WHERE tbd.del_flage = 0
UNION ALL
SELECT td.device_id AS id,
IF(on_line = '1', '1', '0') AS status
FROM tb_device td
WHERE td.del_flag = 0
</select>
<!--效率分析(工程进度分析)-->
<select id="efficiencyAnalysis" resultType="java.util.Map">
SELECT tp.bid_code AS bidCode,
tp.pro_name AS proName,
tgp.plan_id AS planId,
tgp.gx_weight AS gxWeight,
a.gxProgress
FROM tb_project tp
LEFT JOIN tb_gx_plan tgp ON tp.bid_code = tgp.bid_code AND tgp.del_flag = 0
LEFT JOIN (
SELECT tpp.plan_id AS planId,
tpp.gx_progress AS gxProgress
FROM tb_project_progress tpp
INNER JOIN (SELECT MAX( create_time ) AS create_time FROM tb_project_progress GROUP BY plan_id) tpp2 ON tpp.create_time = tpp2.create_time
)a ON tgp.plan_id = a.planId
WHERE tp.del_flag = 0
</select>
</mapper>

View File

@ -94,10 +94,21 @@ public interface IProScheduleMapper {
/**
* 工程为线路时 更新杆塔当前工序
*
* @param vo
* @description
* @author cwchen
* @date 2024/3/16 15:40
*/
void updateGtData(GxPlanProgressVo vo);
/**
* 获取当前工序计划的填报进度
* @param vo
* @return String
* @description
* @author cwchen
* @date 2024/3/28 14:10
*/
String getGxPlanProgress(GxPlanProgressVo vo);
}

View File

@ -99,6 +99,15 @@ public class ProScheduleServiceImpl implements IProScheduleService {
vo.setType(1);
mapper.updateGxPlanData(vo);
}
// 获取当前工序计划的填报进度
String nowGxPlanProgress = mapper.getGxPlanProgress(vo);
if(StringUtils.isNotEmpty(nowGxPlanProgress)){
double aDouble = Double.parseDouble(nowGxPlanProgress);
double bDouble = Double.parseDouble(vo.getGxProgress());
if(bDouble < aDouble){
return AjaxResult.error("当前进度填报需大于上一次填报进度");
}
}
Long timestamp = DateTimeHelper.convertDateStringToTimestamp(vo.getPlanEndTime(), "yyyy-MM-dd");
if (timestamp == null) {
return AjaxResult.error("计划结束时间格式不正确");
@ -117,7 +126,7 @@ public class ProScheduleServiceImpl implements IProScheduleService {
mapper.updateGxPlanData(vo);
}
// 填报工序计划
vo.setCreateTime(DateTimeHelper.getNowDate());
vo.setCreateTime(DateTimeHelper.getNowTime());
String progressId = IdUtils.getUUId();
vo.setProgressId(progressId);
mapper.addGxPlanProgress(vo);

View File

@ -125,4 +125,12 @@
<select id="isFirstFillingGxProgress" resultType="java.lang.Integer">
SELECT COUNT(*) FROM tb_project_progress WHERE plan_id = #{planId}
</select>
<!--获取当前工序计划的填报进度-->
<select id="getGxPlanProgress" resultType="java.lang.String">
SELECT tpp.gx_progress AS gxProgress
FROM tb_project_progress tpp
WHERE plan_id = #{planId}
ORDER BY create_time DESC
LIMIT 1
</select>
</mapper>

View File

@ -65,7 +65,7 @@
<if test="proType == 2">
SELECT gt_id AS id,
gt_name AS name
FROM t_pro_gt WHERE bid_code = #{param}
FROM t_pro_gt WHERE bid_code = #{param} AND del_flag = 0
</if>
</select>
@ -76,9 +76,12 @@
team_leader AS teamLeader,
team_leader_phone AS teamLeaderPhone
FROM tb_work_team
<if test="param!=null and param!=''">
bid_code = #{param}
</if>
<where>
<if test="param!=null and param!=''">
AND bid_code = #{param}
</if>
</where>
</select>
<!--工程下拉选-->
<select id="getProLists" resultType="com.securitycontrol.entity.system.vo.SelectVo">
@ -94,7 +97,7 @@
area_name AS name
FROM tb_area
<where>
bid_code = #{bidCode}
bid_code = #{bidCode} AND del_flag = 0
<if test="gtId !=null and gtId!=''">
AND gt_id = #{gtId}
</if>