执法记录仪导出

This commit is contained in:
guoshengxiong 2025-09-25 10:38:13 +08:00
parent 7340d99c2c
commit 316f7f45e3
8 changed files with 184 additions and 1 deletions

View File

@ -0,0 +1,6 @@
package com.zhgd.xmgl.base;
@FunctionalInterface
public interface QuadConsumer<T, U, V, W> {
void accept(T t, U u, V v, W w);
}

View File

@ -0,0 +1,17 @@
package com.zhgd.xmgl.base;
public interface TreeEntityAware {
public Long getId();
public void setId(Long id);
public Long getParentId();
public void setParentId(Long parentId);
public String getAncestors();
public void setAncestors(String ancestors);
}

View File

@ -33,4 +33,9 @@ public interface DictionaryConstant {
* 安全的责任专业
*/
String XZ_SECURITY_QUALITY_INSPECTION_RECORD_DUTY_MAJOR = "xz_security_quality_inspection_record_duty_major";
/**
* 危大工程模块专项施工方案专家论证方案交底安全技术交底等
*/
String BIG_DANGER_MODULE = "big_danger_module";
}

View File

@ -0,0 +1,52 @@
package com.zhgd.xmgl.util;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import com.zhgd.jeecg.common.util.SpringContextUtils;
import com.zhgd.xmgl.modules.basicdata.entity.DictionaryItem;
import com.zhgd.xmgl.modules.basicdata.service.IDictionaryItemService;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
/**
* 字典工具类
*/
public class DictUtils {
/**
* 批量设置列表中文字典名称
*
* @param <T> 对象类型
* @param <K> 字典key类型
* @param list 对象列表
* @param dictCode 字典编码
* @param keyGetter 从对象中获取字典key的方法引用
* @param nameSetter 给对象设置字典名称的方法引用
* @param projectSn
*/
public static <T, K> void batchSetDictName(Collection<T> list,
String dictCode,
Function<T, K> keyGetter,
BiConsumer<T, String> nameSetter,
@Nullable String projectSn) {
if (CollUtil.isEmpty(list)) {
return;
}
// 获取字典映射
Map<String, DictionaryItem> dictMap = SpringContextUtils.getBean(IDictionaryItemService.class).getDictDataMapByProjectSn(dictCode, projectSn);
for (T item : list) {
String dictKey = Convert.toStr(keyGetter.apply(item));
String dictName = Optional.ofNullable(dictMap.get(dictKey))
.map(DictionaryItem::getName)
.orElse(null);
nameSetter.accept(item, dictName);
}
}
}

View File

@ -248,6 +248,17 @@ public class ExcelUtils {
}
}
public static void exportBigDangerInspectTableLibraryExcel(HttpServletResponse response) {
try {
ClassPathResource classPathResource = new ClassPathResource("excel/bigdanger/检查表导入模板.xlsx");
InputStream inputStream = classPathResource.getInputStream();
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
downLoadExcel("检查表导入模板.xlsx", response, workbook);
} catch (IOException e) {
log.error("error", e);
}
}
public static void exporExcelWorkerTemplate(HttpServletResponse response, List<EntityMap> teamList, List<EntityMap> departmentList, List<WorkerAttendanceGroupV2> groupV2s) {
try {
XSSFWorkbook workbook = getExcelWorkerTemplateWorkbook(teamList, departmentList, groupV2s);

View File

@ -1,6 +1,7 @@
package com.zhgd.xmgl.util;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@ -486,7 +487,7 @@ public class HikVideoUtil {
Map<String, Object> paramMap = new HashMap<String, Object>();// post请求Form表单参数
paramMap.put("cameraIndexCode", cameraIndexCode);
paramMap.put("recordLocation", recordLocation);
paramMap.put("protocol", "rtsp");
paramMap.put("protocol", StrUtil.isNotBlank(protocol) ? protocol : "rtsp");
paramMap.put("transmode", 0);
paramMap.put("beginTime", DateUtils.getISO8601StrWithMs(beginTime));
paramMap.put("endTime", DateUtils.getISO8601StrWithMs(endTime));

View File

@ -0,0 +1,91 @@
package com.zhgd.xmgl.util;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhgd.jeecg.common.execption.OpenAlertException;
import com.zhgd.xmgl.base.QuadConsumer;
import com.zhgd.xmgl.base.TreeEntityAware;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
public class TreeEntityUtil {
/**
* 更新tree接口
*
* @param entity
* @param mapper
* @param sn
* @param getChildrenFunction
* @param updateAncestorsFunction
* @param <T>
* @param <M>
*/
public static <T extends TreeEntityAware, M extends BaseMapper<T>> void updateTreeStructure(
T entity,
M mapper,
String sn,
Function<Long, List<T>> getChildrenFunction,
QuadConsumer<String, String, String, Long> updateAncestorsFunction) {
T oldPo = mapper.selectById(entity.getId());
if (oldPo == null) {
throw new OpenAlertException("数据不存在");
}
if (!Objects.equals(oldPo.getParentId(), entity.getParentId())) {
if (Objects.equals(entity.getId(), entity.getParentId())) {
throw new OpenAlertException("不能移动到其自身");
}
List<T> children = getChildrenFunction.apply(entity.getId());
for (T child : children) {
if (child.getId().equals(entity.getParentId())) {
throw new OpenAlertException("不能移动到其自身下级");
}
}
T pOrg = mapper.selectById(entity.getParentId());
boolean top = entity.getParentId() == null || entity.getParentId() == 0;
if (top) {
entity.setParentId(0L);
entity.setAncestors("0");
} else {
if (pOrg == null) {
throw new OpenAlertException("上级不存在");
}
entity.setAncestors(pOrg.getAncestors() + "," + pOrg.getId());
}
updateAncestorsFunction.accept(
oldPo.getAncestors(),
entity.getAncestors(),
sn,
entity.getId()
);
} else {
entity.setAncestors(null);
}
}
/**
* 添加tree接口
*
* @param entity
* @param baseMapper
* @param <T>
*/
public static <T extends TreeEntityAware> void addTreeStructure(T entity, BaseMapper<T> baseMapper) {
boolean top = entity.getParentId() == null || entity.getParentId() == 0;
if (top) {
entity.setParentId(0L);
entity.setAncestors("0");
} else {
T pOrg = baseMapper.selectById(entity.getParentId());
if (pOrg != null) {
entity.setAncestors(pOrg.getAncestors() + "," + pOrg.getId());
}
}
}
}