金林湾-项目监管大屏的安全问题修改成实时的
This commit is contained in:
parent
9a80cf9a74
commit
c963a88be3
@ -9,7 +9,6 @@ import com.zhgd.xmgl.modules.dangerous.entity.vo.AllTodayDataHdirVO;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.vo.AllWeekDataHdirVO;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.vo.TotalAndWeekHiddenDanger;
|
||||
import com.zhgd.xmgl.modules.dangerous.service.IHiddenDangerInspectRecordService;
|
||||
import com.zhgd.xmgl.util.MessageUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
@ -150,19 +149,7 @@ public class HiddenDangerInspectRecordController {
|
||||
@ApiOperation(value = "编辑隐患检查记录信息", notes = "编辑隐患检查记录信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<HiddenDangerInspectRecord> edit(@RequestBody HiddenDangerInspectRecord hiddenDangerInspectRecord) {
|
||||
Result<HiddenDangerInspectRecord> result = new Result<HiddenDangerInspectRecord>();
|
||||
HiddenDangerInspectRecord hiddenDangerInspectRecordEntity = hiddenDangerInspectRecordService.getById(hiddenDangerInspectRecord.getId());
|
||||
if (hiddenDangerInspectRecordEntity == null) {
|
||||
result.error500(MessageUtil.get("notFindErr"));
|
||||
} else {
|
||||
boolean ok = hiddenDangerInspectRecordService.updateById(hiddenDangerInspectRecord);
|
||||
//TODO 返回false说明什么?
|
||||
if (ok) {
|
||||
result.successMsg(MessageUtil.get("editSucess"));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return hiddenDangerInspectRecordService.edit(hiddenDangerInspectRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -5,14 +5,16 @@
|
||||
<select id="selectHiddenDangerStateTrendByWeek"
|
||||
resultType="com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics">
|
||||
SELECT
|
||||
hd.id,
|
||||
date_sub(hd.create_time,interval dayofweek(hd.create_time)-2 day) create_time,
|
||||
sum(hd.increase_num) increase_num,
|
||||
sum(hd.solve_num) solve_num,
|
||||
sum(hd.un_resolve_num) un_resolve_num,
|
||||
hd.project_sn
|
||||
FROM `hidden_danger_inspection_statistics` hd
|
||||
GROUP BY YEARWEEK(hd.create_time)
|
||||
hd.id,
|
||||
date_sub(hd.create_time,INTERVAL WEEKDAY(hd.create_time) + 0 DAY) create_time,
|
||||
sum( hd.increase_num ) increase_num,
|
||||
sum( hd.solve_num ) solve_num,
|
||||
sum( hd.un_resolve_num ) un_resolve_num,
|
||||
hd.project_sn
|
||||
FROM
|
||||
`hidden_danger_inspection_statistics` hd
|
||||
GROUP BY
|
||||
YEARWEEK(hd.create_time,1)
|
||||
HAVING hd.project_sn = #{projectSn}
|
||||
ORDER BY hd.create_time DESC LIMIT #{offsetWeek}
|
||||
</select>
|
||||
|
||||
@ -2,6 +2,7 @@ package com.zhgd.xmgl.modules.dangerous.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics;
|
||||
@ -72,4 +73,7 @@ public interface IHiddenDangerInspectRecordService extends IService<HiddenDanger
|
||||
List<HiddenDangerInspectionStatistics> selectHiddenDangerStateTrend(Map<String, Object> map);
|
||||
|
||||
List<HiddenDangerInspectionStatistics> selectHiddenDangerStateTrendByWeek(Map<String, Object> map);
|
||||
|
||||
Result<HiddenDangerInspectRecord> edit(HiddenDangerInspectRecord hiddenDangerInspectRecord);
|
||||
|
||||
}
|
||||
|
||||
@ -1,14 +1,17 @@
|
||||
package com.zhgd.xmgl.modules.dangerous.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.call.SanjiangDataCall;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.INoticeService;
|
||||
@ -25,11 +28,12 @@ import com.zhgd.xmgl.modules.dangerous.mapper.HiddenDangerInspectRecordMapper;
|
||||
import com.zhgd.xmgl.modules.dangerous.mapper.HiddenDangerInspectionStatisticsMapper;
|
||||
import com.zhgd.xmgl.modules.dangerous.mapper.HiddenDangerRectifyRecordMapper;
|
||||
import com.zhgd.xmgl.modules.dangerous.service.IHiddenDangerInspectRecordService;
|
||||
import com.zhgd.xmgl.modules.dangerous.service.IHiddenDangerInspectionStatisticsService;
|
||||
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
||||
import com.zhgd.xmgl.modules.quality.service.impl.QualityInspectionRecordServiceImpl;
|
||||
import com.zhgd.xmgl.modules.worker.mapper.EnterpriseInfoMapper;
|
||||
import com.zhgd.xmgl.util.JxlExcelUtils;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import com.zhgd.xmgl.util.MessageUtil;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -49,6 +53,8 @@ import java.util.*;
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class HiddenDangerInspectRecordServiceImpl extends ServiceImpl<HiddenDangerInspectRecordMapper, HiddenDangerInspectRecord> implements IHiddenDangerInspectRecordService {
|
||||
@Autowired
|
||||
IHiddenDangerInspectionStatisticsService hiddenDangerInspectionStatisticsService;
|
||||
@Autowired
|
||||
private HiddenDangerInspectRecordMapper hiddenDangerInspectRecordMapper;
|
||||
@Autowired
|
||||
@ -70,6 +76,7 @@ public class HiddenDangerInspectRecordServiceImpl extends ServiceImpl<HiddenDang
|
||||
|
||||
@Override
|
||||
public void deleteHiddenDangerInspectRecord(Long id) {
|
||||
HiddenDangerInspectRecord hiddenDangerInspectRecord = hiddenDangerInspectRecordMapper.selectById(id);
|
||||
hiddenDangerInspectRecordMapper.deleteById(id);
|
||||
QueryWrapper<HiddenDangerRectifyRecord> qu = new QueryWrapper<>();
|
||||
qu.lambda().eq(HiddenDangerRectifyRecord::getInspectId, id);
|
||||
@ -79,6 +86,7 @@ public class HiddenDangerInspectRecordServiceImpl extends ServiceImpl<HiddenDang
|
||||
dangerInspectionAcceptanceTableResultMapper.delete(queryWrapper);
|
||||
|
||||
sanjiangDataCall.sendDeleteHiddenDangerInspectRecord(id);
|
||||
saveHiddenDangerInspectionStatistics(hiddenDangerInspectRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -143,6 +151,22 @@ public class HiddenDangerInspectRecordServiceImpl extends ServiceImpl<HiddenDang
|
||||
}
|
||||
|
||||
sanjiangDataCall.sendAddHiddenDangerInspectionRecord(hiddenDangerInspectRecord);
|
||||
saveHiddenDangerInspectionStatistics(hiddenDangerInspectRecord);
|
||||
}
|
||||
|
||||
private void saveHiddenDangerInspectionStatistics(HiddenDangerInspectRecord hdir) {
|
||||
Date createTime = new Date();
|
||||
DateTime startTime = DateUtil.beginOfDay(createTime);
|
||||
DateTime endTime = DateUtil.endOfDay(createTime);
|
||||
String projectSn = hdir.getProjectSn();
|
||||
HiddenDangerInspectionStatistics statistics = hiddenDangerInspectRecordMapper.statisticsByStatue(startTime, endTime, projectSn);
|
||||
statistics.setProjectSn(projectSn);
|
||||
statistics.setCreateTime(createTime);
|
||||
//删除原来
|
||||
hiddenDangerInspectionStatisticsService.remove(new LambdaQueryWrapper<HiddenDangerInspectionStatistics>()
|
||||
.eq(HiddenDangerInspectionStatistics::getProjectSn, projectSn)
|
||||
.eq(HiddenDangerInspectionStatistics::getCreateTime, DateUtil.formatDate(createTime)));
|
||||
hiddenDangerInspectionStatisticsService.save(statistics);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -448,53 +472,29 @@ public class HiddenDangerInspectRecordServiceImpl extends ServiceImpl<HiddenDang
|
||||
Integer offsetWeek = MapUtils.getInteger(map, "offsetWeek");
|
||||
String projectSn = MapUtils.getString(map, "projectSn");
|
||||
|
||||
int defaultOffsetWeek = 5;
|
||||
if (offsetWeek == null || offsetWeek <= 0) {
|
||||
offsetWeek = defaultOffsetWeek;
|
||||
map.put("offsetWeek", 5);
|
||||
}
|
||||
map.put("offsetWeek", offsetWeek + 1);
|
||||
List<HiddenDangerInspectionStatistics> statisticsList = hiddenDangerInspectionStatisticsMapper.selectHiddenDangerStateTrendByWeek(map);
|
||||
Date thisMonday = getThisMonday();
|
||||
if (CollectionUtils.isNotEmpty(statisticsList)) {
|
||||
HiddenDangerInspectionStatistics statistics = statisticsList.get(0);
|
||||
if (statistics != null) {
|
||||
//删除最新的没有完全统计的一周的数据,一条数据
|
||||
statisticsList.remove(0);
|
||||
}
|
||||
}
|
||||
//数据不够时补充前面的为0
|
||||
if (statisticsList.size() < defaultOffsetWeek) {
|
||||
Date d = null;
|
||||
int size = statisticsList.size();
|
||||
if (CollectionUtils.isNotEmpty(statisticsList)) {
|
||||
d = statisticsList.get(size - 1).getCreateTime();
|
||||
} else {
|
||||
d = thisMonday;
|
||||
}
|
||||
d = DateUtil.offsetDay(d, -7);
|
||||
for (int i = 0; i < defaultOffsetWeek - size; i++) {
|
||||
HiddenDangerInspectionStatistics e = new HiddenDangerInspectionStatistics();
|
||||
e.setCreateTime(d);
|
||||
e.setIncreaseNum(0);
|
||||
e.setSolveNum(0);
|
||||
e.setUnResolveNum(0);
|
||||
e.setProjectSn(projectSn);
|
||||
d = DateUtil.offsetDay(d, -7);
|
||||
statisticsList.add(e);
|
||||
}
|
||||
}
|
||||
Collections.sort(statisticsList, (o1, o2) -> o1.getCreateTime().compareTo(o2.getCreateTime()));
|
||||
statisticsList.stream().forEach(o -> o.setCreateTime(DateUtil.offsetDay(o.getCreateTime(), 7)));
|
||||
return statisticsList;
|
||||
}
|
||||
|
||||
public Date getThisMonday() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
// 设置周一为第一天
|
||||
cal.setFirstDayOfWeek(Calendar.MONDAY);
|
||||
// 时间设置到周一,此时时间为周一的日期
|
||||
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
|
||||
return cal.getTime();
|
||||
@Override
|
||||
public Result<HiddenDangerInspectRecord> edit(HiddenDangerInspectRecord hiddenDangerInspectRecord) {
|
||||
Result<HiddenDangerInspectRecord> result = new Result<HiddenDangerInspectRecord>();
|
||||
HiddenDangerInspectRecord hiddenDangerInspectRecordEntity = getById(hiddenDangerInspectRecord.getId());
|
||||
if (hiddenDangerInspectRecordEntity == null) {
|
||||
result.error500(MessageUtil.get("notFindErr"));
|
||||
} else {
|
||||
boolean ok = updateById(hiddenDangerInspectRecord);
|
||||
saveHiddenDangerInspectionStatistics(hiddenDangerInspectRecord);
|
||||
if (ok) {
|
||||
result.successMsg(MessageUtil.get("editSucess"));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -6,13 +6,11 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.zhgd.xmgl.config.RundeWSClient;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerRectifyRecord;
|
||||
import com.zhgd.xmgl.modules.dangerous.mapper.HiddenDangerInspectRecordMapper;
|
||||
import com.zhgd.xmgl.modules.dangerous.service.IHiddenDangerInspectRecordService;
|
||||
import com.zhgd.xmgl.modules.dangerous.service.IHiddenDangerInspectionStatisticsService;
|
||||
import com.zhgd.xmgl.modules.helmet.entity.RundeGroup;
|
||||
import com.zhgd.xmgl.modules.helmet.service.RundeGroupService;
|
||||
@ -115,15 +113,20 @@ public class RundeTask {
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
public void hiddenDangerStatistics() {
|
||||
DateTime startTime = DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), -1));
|
||||
DateTime endTime = DateUtil.endOfDay(DateUtil.offsetDay(new Date(), -1));
|
||||
DateTime createTime = DateUtil.offsetDay(new Date(), -1);
|
||||
DateTime startTime = DateUtil.beginOfDay(createTime);
|
||||
DateTime endTime = DateUtil.endOfDay(createTime);
|
||||
List<String> projectSns = hiddenDangerInspectRecordMapper.getGroupByProjectSn();
|
||||
List<HiddenDangerInspectionStatistics> list = new ArrayList<>();
|
||||
for (String projectSn : projectSns) {
|
||||
HiddenDangerInspectionStatistics statistics = hiddenDangerInspectRecordMapper.statisticsByStatue(startTime, endTime, projectSn);
|
||||
statistics.setProjectSn(projectSn);
|
||||
statistics.setCreateTime(DateUtil.offsetDay(new Date(), -1));
|
||||
statistics.setCreateTime(createTime);
|
||||
list.add(statistics);
|
||||
//删除原来
|
||||
hiddenDangerInspectionStatisticsService.remove(new LambdaQueryWrapper<HiddenDangerInspectionStatistics>()
|
||||
.eq(HiddenDangerInspectionStatistics::getProjectSn, projectSn)
|
||||
.eq(HiddenDangerInspectionStatistics::getCreateTime, DateUtil.formatDate(createTime)));
|
||||
}
|
||||
hiddenDangerInspectionStatisticsService.saveBatch(list);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user