|
@@ -1,5 +1,8 @@
|
|
|
package com.ruoyi.web.controller.qdtl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
@@ -7,8 +10,12 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
+import com.ruoyi.qdtl.domain.MissLoactionPoint;
|
|
|
+import com.ruoyi.qdtl.domain.TlInspectionLocation;
|
|
|
import com.ruoyi.qdtl.domain.TlInspectionLocationLog;
|
|
|
import com.ruoyi.qdtl.service.ITlInspectionLocationLogService;
|
|
|
+import com.ruoyi.qdtl.service.ITlInspectionLocationService;
|
|
|
+import com.ruoyi.system.service.ISysRoleService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -20,7 +27,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 巡检记录管理Controller
|
|
@@ -33,16 +45,29 @@ import java.util.List;
|
|
|
public class TlInspectionLocationLogController extends BaseController {
|
|
|
@Autowired
|
|
|
private ITlInspectionLocationLogService tlInspectionLocationLogService;
|
|
|
+ @Autowired
|
|
|
+ private ISysRoleService sysRoleService;
|
|
|
+ @Autowired
|
|
|
+ private ITlInspectionLocationService locationService;
|
|
|
|
|
|
/**
|
|
|
* 查询巡检记录管理列表
|
|
|
*/
|
|
|
@GetMapping("/list")
|
|
|
public TableDataInfo list(TlInspectionLocationLog tlInspectionLocationLog) {
|
|
|
+ Set<String> roleSet = sysRoleService.selectRolePermissionByUserId(getUserId());
|
|
|
startPage();
|
|
|
if (StrUtil.isNotBlank(tlInspectionLocationLog.getAreaId())) {
|
|
|
- tlInspectionLocationLog.setAreaIds(StrUtil.split(tlInspectionLocationLog.getAreaId(), ','));
|
|
|
+ Set<String> split = new HashSet<>(StrUtil.split(tlInspectionLocationLog.getAreaId(), ','));
|
|
|
+ if (!roleSet.contains("admin")) {
|
|
|
+ split = CollUtil.intersectionDistinct(roleSet, split);
|
|
|
+ }
|
|
|
+ tlInspectionLocationLog.setAreaIds(split);
|
|
|
tlInspectionLocationLog.setAreaId("");
|
|
|
+ } else {
|
|
|
+ if (!roleSet.contains("admin")) {
|
|
|
+ tlInspectionLocationLog.setAreaIds(roleSet);
|
|
|
+ }
|
|
|
}
|
|
|
List<TlInspectionLocationLog> list = tlInspectionLocationLogService.selectTlInspectionLocationLogList(tlInspectionLocationLog);
|
|
|
return getDataTable(list);
|
|
@@ -57,7 +82,7 @@ public class TlInspectionLocationLogController extends BaseController {
|
|
|
@GetMapping("/trail/list")
|
|
|
public AjaxResult trailList(TlInspectionLocationLog tlInspectionLocationLog) {
|
|
|
if (StrUtil.isNotBlank(tlInspectionLocationLog.getAreaId())) {
|
|
|
- tlInspectionLocationLog.setAreaIds(StrUtil.split(tlInspectionLocationLog.getAreaId(), ','));
|
|
|
+ tlInspectionLocationLog.setAreaIds(new HashSet<>(StrUtil.split(tlInspectionLocationLog.getAreaId(), ',')));
|
|
|
tlInspectionLocationLog.setAreaId("");
|
|
|
}
|
|
|
List<TlInspectionLocationLog> list = tlInspectionLocationLogService.selectTlInspectionLocationLogTrailList(tlInspectionLocationLog);
|
|
@@ -70,15 +95,60 @@ public class TlInspectionLocationLogController extends BaseController {
|
|
|
@Log(title = "巡检记录管理", businessType = BusinessType.EXPORT)
|
|
|
@PostMapping("/export")
|
|
|
public void export(HttpServletResponse response, TlInspectionLocationLog tlInspectionLocationLog) {
|
|
|
+ Set<String> roleSet = sysRoleService.selectRolePermissionByUserId(getUserId());
|
|
|
if (StrUtil.isNotBlank(tlInspectionLocationLog.getAreaId())) {
|
|
|
- tlInspectionLocationLog.setAreaIds(StrUtil.split(tlInspectionLocationLog.getAreaId(), ','));
|
|
|
+ Set<String> split = new HashSet<>(StrUtil.split(tlInspectionLocationLog.getAreaId(), ','));
|
|
|
+ if (!roleSet.contains("admin")) {
|
|
|
+ split = CollUtil.intersectionDistinct(roleSet, split);
|
|
|
+ }
|
|
|
+ tlInspectionLocationLog.setAreaIds(split);
|
|
|
tlInspectionLocationLog.setAreaId("");
|
|
|
+ } else {
|
|
|
+ if (!roleSet.contains("admin")) {
|
|
|
+ tlInspectionLocationLog.setAreaIds(roleSet);
|
|
|
+ }
|
|
|
}
|
|
|
List<TlInspectionLocationLog> list = tlInspectionLocationLogService.selectTlInspectionLocationLogList(tlInspectionLocationLog);
|
|
|
ExcelUtil<TlInspectionLocationLog> util = new ExcelUtil<TlInspectionLocationLog>(TlInspectionLocationLog.class);
|
|
|
util.exportExcel(response, list, "巡检记录管理数据");
|
|
|
}
|
|
|
|
|
|
+ @Log(title = "漏打巡检点导出", businessType = BusinessType.EXPORT)
|
|
|
+ @PostMapping("/missExport")
|
|
|
+ public void missExport(HttpServletResponse response, TlInspectionLocationLog tlInspectionLocationLog) {
|
|
|
+ // 查询每个镇所有的点位
|
|
|
+ List<TlInspectionLocation> locations = locationService.selectLocationList();
|
|
|
+ Set<String> locationsSet = locations.stream().map(TlInspectionLocation::getLocationCode).collect(Collectors.toSet());
|
|
|
+ Map<String, TlInspectionLocation> locationName = locations.stream().collect(Collectors.toMap(TlInspectionLocation::getLocationCode, a -> a));
|
|
|
+// Map<Long, List<TlInspectionLocation>> locationCollect = locations.stream().collect(Collectors.groupingBy(TlInspectionLocation::getAreaId));
|
|
|
+ // 查询近一个月内所有打卡记录
|
|
|
+ TlInspectionLocationLog bean = new TlInspectionLocationLog();
|
|
|
+ DateTime endDate = DateUtil.date();
|
|
|
+ DateTime startDate = DateUtil.offsetDay(endDate, -30);
|
|
|
+ bean.setBeginTime(DateUtil.formatDateTime(startDate));
|
|
|
+ bean.setEndTime(DateUtil.formatDateTime(endDate));
|
|
|
+ List<TlInspectionLocationLog> locationLogList = tlInspectionLocationLogService.selectTlInspectionLocationLogList(bean);
|
|
|
+ // 解析根据日期分组
|
|
|
+ Map<String, List<TlInspectionLocationLog>> dateCollect = locationLogList.stream().collect(Collectors.groupingBy(a -> DateUtil.formatDate(a.getCreateTime())));
|
|
|
+ List<MissLoactionPoint> list = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, List<TlInspectionLocationLog>> stringListEntry : dateCollect.entrySet()) {
|
|
|
+ String dateStr = stringListEntry.getKey();
|
|
|
+ List<TlInspectionLocationLog> value = stringListEntry.getValue();
|
|
|
+ Set<String> cardCollect = value.stream().map(TlInspectionLocationLog::getCheckpointCard).collect(Collectors.toSet());
|
|
|
+ List<String> pointList = CollUtil.subtractToList(locationsSet, cardCollect);
|
|
|
+ for (String s : pointList) {
|
|
|
+ MissLoactionPoint add = new MissLoactionPoint();
|
|
|
+ add.setDateStr(dateStr);
|
|
|
+ add.setLocationName(locationName.get(s).getLocationName());
|
|
|
+ add.setLocationCode(locationName.get(s).getLocationCode());
|
|
|
+ list.add(add);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ CollUtil.sortByProperty(list, "dateStr");
|
|
|
+ ExcelUtil<MissLoactionPoint> util = new ExcelUtil<>(MissLoactionPoint.class);
|
|
|
+ util.exportExcel(response, list, "近一个月内漏打记录数据");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取巡检记录管理详细信息
|
|
|
*/
|