bug修复
This commit is contained in:
parent
97387ce2ef
commit
7bb923bdb0
@ -2,6 +2,7 @@ package com.zhgd.xmgl.base.entity.vo;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.zhgd.xmgl.util.DateUtils;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.*;
|
||||
@ -44,7 +45,7 @@ public class FlexibleBigScreenVo {
|
||||
*
|
||||
* @param rtVo FlexibleBigScreenVo
|
||||
* @param days 日期的list
|
||||
* @param format 需要转换的时间格式
|
||||
* @param format 转换后的时间格式
|
||||
* @return
|
||||
*/
|
||||
public static FlexibleBigScreenVo fillTrendVos(FlexibleBigScreenVo rtVo, List<String> days, String format) {
|
||||
@ -62,22 +63,12 @@ public class FlexibleBigScreenVo {
|
||||
vo.put(key, 0);
|
||||
}
|
||||
}
|
||||
vo.put(timeKey, DateUtil.format(parse(vo.get(timeKey).toString()), format));
|
||||
vo.put(timeKey, DateUtil.format(DateUtils.parse(vo.get(timeKey).toString()), format));
|
||||
rtList.add(vo);
|
||||
}
|
||||
rtVo.setSource(rtList);
|
||||
return rtVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
private static DateTime parse(String str) {
|
||||
if (Objects.equals(str.length(),7)) {
|
||||
return DateUtil.parse(str, "yyyy-MM");
|
||||
}
|
||||
return DateUtil.parse(str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package com.zhgd.xmgl.base.entity.vo;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.zhgd.xmgl.util.DateUtils;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -24,7 +24,7 @@ public class TrendVo {
|
||||
*
|
||||
* @param list 数据的list
|
||||
* @param days 日期的list
|
||||
* @param format 需要转换的时间格式
|
||||
* @param format 转换后的时间格式
|
||||
* @return
|
||||
*/
|
||||
public static List<TrendVo> fillTrendVos(List<TrendVo> list, List<String> days, String format) {
|
||||
@ -37,21 +37,10 @@ public class TrendVo {
|
||||
vo.setY("0");
|
||||
vo.setX(day);
|
||||
}
|
||||
vo.setX(DateUtil.format(parse(vo.getX(), format), format));
|
||||
vo.setX(DateUtil.format(DateUtils.parse(vo.getX()), format));
|
||||
rtList.add(vo);
|
||||
}
|
||||
return rtList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param str
|
||||
* @param format
|
||||
* @return
|
||||
*/
|
||||
private static DateTime parse(String str, String format) {
|
||||
if ("yyyy-MM".equals(format)) {
|
||||
return DateUtil.parse(str, format);
|
||||
}
|
||||
return DateUtil.parse(str);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.base.entity.vo.TrendVo;
|
||||
import com.zhgd.xmgl.modules.bigdevice.entity.GantryCraneWorkCycle;
|
||||
import com.zhgd.xmgl.modules.bigdevice.entity.vo.CountGantryCraneWorkCycleVo;
|
||||
import com.zhgd.xmgl.modules.bigdevice.service.IBigDeviceDiscloseRecordService;
|
||||
import com.zhgd.xmgl.modules.bigdevice.service.IGantryCraneWorkCycleService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@ -146,4 +145,14 @@ public class GantryCraneWorkCycleController {
|
||||
return Result.success(gantryCraneWorkCycleService.countGantryCraneWorkCycle(paramMap));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "工作时长分析(h)", notes = "工作时长分析(h)", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "devSn", value = "设备编号", dataType = "String", paramType = "body", required = false),
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目sn", dataType = "String", paramType = "body", required = false),
|
||||
@ApiImplicitParam(name = "type", value = "查询天数:1、近7日、2:本月", dataType = "Integer", paramType = "body", required = true),
|
||||
})
|
||||
@PostMapping(value = "/workTimeAnalysis")
|
||||
public Result<List<TrendVo>> workTimeAnalysis(@ApiIgnore @RequestBody HashMap<String, Object> paramMap) {
|
||||
return Result.success(gantryCraneWorkCycleService.workTimeAnalysis(paramMap));
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,4 +29,6 @@ public interface GantryCraneWorkCycleMapper extends BaseMapper<GantryCraneWorkCy
|
||||
List<TrendVo> countGantryCraneWorkCycleNumEveryday(Map<String, Object> map);
|
||||
|
||||
CountGantryCraneWorkCycleVo countGantryCraneWorkCycle(HashMap<String, Object> paramMap);
|
||||
|
||||
List<TrendVo> workTimeAnalysis(HashMap<String, Object> paramMap);
|
||||
}
|
||||
|
||||
@ -44,9 +44,9 @@
|
||||
|
||||
<select id="countGantryCraneWorkCycle"
|
||||
resultType="com.zhgd.xmgl.modules.bigdevice.entity.vo.CountGantryCraneWorkCycleVo">
|
||||
select ifnull(sum(ifnull(work_time,0))/3600,0) workTimeCount
|
||||
select ifnull(sum(ifnull(work_time, 0)) / 3600, 0) workTimeCount
|
||||
from gantry_crane_work_cycle
|
||||
where 1=1
|
||||
where 1 = 1
|
||||
<if test="projectSn != null and projectSn != ''">
|
||||
and project_sn = #{projectSn}
|
||||
</if>
|
||||
@ -54,4 +54,20 @@
|
||||
and dev_sn = #{devSn}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="workTimeAnalysis" resultType="com.zhgd.xmgl.base.entity.vo.TrendVo">
|
||||
SELECT date_format(work_time, '%Y-%m-%d') x, count(*) y
|
||||
FROM gantry_crane_work_cycle
|
||||
where 1=1
|
||||
<if test="devSn != null and devSn != ''">
|
||||
and dev_sn = #{devSn}
|
||||
</if>
|
||||
<if test="type == '1'.toString()">
|
||||
and add_time >= date_sub(current_date, interval 15 day)
|
||||
</if>
|
||||
<if test="type == '2'.toString()">
|
||||
and add_time >= date_sub(current_date, interval 50 day)
|
||||
</if>
|
||||
group by x
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@ -21,13 +21,15 @@ import java.util.Map;
|
||||
|
||||
public interface IGantryCraneWorkCycleService extends IService<GantryCraneWorkCycle> {
|
||||
|
||||
IPage<EntityMap> queryGantryCraneWorkCyclePageList(Map<String, Object> map);
|
||||
IPage<EntityMap> queryGantryCraneWorkCyclePageList(Map<String, Object> map);
|
||||
|
||||
List<EntityMap> selectGantryCraneWorkCycleList(Map<String, Object> map);
|
||||
List<EntityMap> selectGantryCraneWorkCycleList(Map<String, Object> map);
|
||||
|
||||
void saveGantryCraneWorkCycle(GantryCraneWorkCycle gantryCraneWorkCycle);
|
||||
void saveGantryCraneWorkCycle(GantryCraneWorkCycle gantryCraneWorkCycle);
|
||||
|
||||
List<TrendVo> countGantryCraneWorkCycleNumEveryday(Map<String, Object> map);
|
||||
List<TrendVo> countGantryCraneWorkCycleNumEveryday(Map<String, Object> map);
|
||||
|
||||
CountGantryCraneWorkCycleVo countGantryCraneWorkCycle(HashMap<String, Object> paramMap);
|
||||
CountGantryCraneWorkCycleVo countGantryCraneWorkCycle(HashMap<String, Object> paramMap);
|
||||
|
||||
List<TrendVo> workTimeAnalysis(HashMap<String, Object> paramMap);
|
||||
}
|
||||
|
||||
@ -82,4 +82,18 @@ public class GantryCraneWorkCycleServiceImpl extends ServiceImpl<GantryCraneWork
|
||||
public CountGantryCraneWorkCycleVo countGantryCraneWorkCycle(HashMap<String, Object> paramMap) {
|
||||
return baseMapper.countGantryCraneWorkCycle(paramMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TrendVo> workTimeAnalysis(HashMap<String, Object> paramMap) {
|
||||
List<TrendVo> trendVos = gantryCraneWorkCycleMapper.workTimeAnalysis(paramMap);
|
||||
List<String> days;
|
||||
if (Objects.equals(MapUtils.getInteger(paramMap, "type"), 1)) {
|
||||
days = DateUtils.getDateStrList(60, "yyyy-MM-dd");
|
||||
} else if (Objects.equals(MapUtils.getInteger(paramMap, "type"), 2)) {
|
||||
days = DateUtils.getDaysBefore(400);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return TrendVo.fillTrendVos(trendVos, days, "MM-dd");
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,4 +10,6 @@ public class ProjectExtDto {
|
||||
private String projectSn;
|
||||
@ApiModelProperty(value = "拓展字段2")
|
||||
private String extend2;
|
||||
@ApiModelProperty(value = "拓展字段3")
|
||||
private String extend3;
|
||||
}
|
||||
|
||||
@ -178,6 +178,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||
*/
|
||||
@Value("${fmsMonitoringScreenPageUrl:}")
|
||||
private String fmsMonitoringScreenPageUrl;
|
||||
String PROJECT_PREFIX_KEY = "projectInfoBySn:";
|
||||
|
||||
|
||||
public List<String> getProjectSnList(String sn) {
|
||||
@ -211,7 +212,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||
if (StringUtils.isBlank(projectSn)) {
|
||||
return null;
|
||||
}
|
||||
ProjectInfoExtVo info = redisRepository.getOrSetEx("projectInfoBySn:" + projectSn, (() -> projectMapper.getProjectInfoBySn(map)));
|
||||
ProjectInfoExtVo info = redisRepository.getOrSetEx(PROJECT_PREFIX_KEY + projectSn, (() -> projectMapper.getProjectInfoBySn(map)));
|
||||
if (info == null) {
|
||||
throw new NullPointerException(" 当前查询条件结果不存在!");
|
||||
}
|
||||
@ -315,6 +316,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||
Project project = BeanUtil.toBean(dto, Project.class);
|
||||
projectMapper.update(project, new LambdaQueryWrapper<Project>()
|
||||
.eq(Project::getProjectSn, dto.getProjectSn()));
|
||||
redisRepository.del(PROJECT_PREFIX_KEY + dto.getProjectSn());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -544,6 +544,19 @@ public class DateUtils {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* str转换成datetime格式
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static DateTime parse(String str) {
|
||||
if (Objects.equals(str.length(), 7)) {
|
||||
return DateUtil.parse(str, "yyyy-MM");
|
||||
}
|
||||
return DateUtil.parse(str);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(getNowWeekAllDayList());
|
||||
System.out.println(getDateStrList(100, "HH:mm"));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user