执法记录仪导出
This commit is contained in:
parent
7340d99c2c
commit
316f7f45e3
6
src/main/java/com/zhgd/xmgl/base/QuadConsumer.java
Normal file
6
src/main/java/com/zhgd/xmgl/base/QuadConsumer.java
Normal 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);
|
||||
}
|
||||
17
src/main/java/com/zhgd/xmgl/base/TreeEntityAware.java
Normal file
17
src/main/java/com/zhgd/xmgl/base/TreeEntityAware.java
Normal 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);
|
||||
|
||||
}
|
||||
@ -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";
|
||||
|
||||
}
|
||||
|
||||
52
src/main/java/com/zhgd/xmgl/util/DictUtils.java
Normal file
52
src/main/java/com/zhgd/xmgl/util/DictUtils.java
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
|
||||
@ -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));
|
||||
|
||||
91
src/main/java/com/zhgd/xmgl/util/TreeEntityUtil.java
Normal file
91
src/main/java/com/zhgd/xmgl/util/TreeEntityUtil.java
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
src/main/resources/excel/执法记录仪导入模板.xlsx
Normal file
BIN
src/main/resources/excel/执法记录仪导入模板.xlsx
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user