bug修复

This commit is contained in:
guo 2023-12-18 14:55:59 +08:00
parent 97387ce2ef
commit 7bb923bdb0
10 changed files with 75 additions and 35 deletions

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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));
}
}

View File

@ -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);
}

View File

@ -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>

View File

@ -30,4 +30,6 @@ public interface IGantryCraneWorkCycleService extends IService<GantryCraneWorkCy
List<TrendVo> countGantryCraneWorkCycleNumEveryday(Map<String, Object> map);
CountGantryCraneWorkCycleVo countGantryCraneWorkCycle(HashMap<String, Object> paramMap);
List<TrendVo> workTimeAnalysis(HashMap<String, Object> paramMap);
}

View File

@ -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");
}
}

View File

@ -10,4 +10,6 @@ public class ProjectExtDto {
private String projectSn;
@ApiModelProperty(value = "拓展字段2")
private String extend2;
@ApiModelProperty(value = "拓展字段3")
private String extend3;
}

View File

@ -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

View File

@ -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"));