diff --git a/src/main/java/com/zhgd/xmgl/base/QuadConsumer.java b/src/main/java/com/zhgd/xmgl/base/QuadConsumer.java new file mode 100644 index 000000000..af59e926a --- /dev/null +++ b/src/main/java/com/zhgd/xmgl/base/QuadConsumer.java @@ -0,0 +1,6 @@ +package com.zhgd.xmgl.base; + +@FunctionalInterface +public interface QuadConsumer { + void accept(T t, U u, V v, W w); +} diff --git a/src/main/java/com/zhgd/xmgl/base/TreeEntityAware.java b/src/main/java/com/zhgd/xmgl/base/TreeEntityAware.java new file mode 100644 index 000000000..0606f1c89 --- /dev/null +++ b/src/main/java/com/zhgd/xmgl/base/TreeEntityAware.java @@ -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); + +} diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/constant/DictionaryConstant.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/constant/DictionaryConstant.java index b96af7111..533eeaf60 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/constant/DictionaryConstant.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/constant/DictionaryConstant.java @@ -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"; + } diff --git a/src/main/java/com/zhgd/xmgl/util/DictUtils.java b/src/main/java/com/zhgd/xmgl/util/DictUtils.java new file mode 100644 index 000000000..557faf37e --- /dev/null +++ b/src/main/java/com/zhgd/xmgl/util/DictUtils.java @@ -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 对象类型 + * @param 字典key类型 + * @param list 对象列表 + * @param dictCode 字典编码 + * @param keyGetter 从对象中获取字典key的方法引用 + * @param nameSetter 给对象设置字典名称的方法引用 + * @param projectSn + */ + public static void batchSetDictName(Collection list, + String dictCode, + Function keyGetter, + BiConsumer nameSetter, + @Nullable String projectSn) { + if (CollUtil.isEmpty(list)) { + return; + } + + // 获取字典映射 + Map 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); + } + } +} diff --git a/src/main/java/com/zhgd/xmgl/util/ExcelUtils.java b/src/main/java/com/zhgd/xmgl/util/ExcelUtils.java index 8357a88af..fadf4ea68 100644 --- a/src/main/java/com/zhgd/xmgl/util/ExcelUtils.java +++ b/src/main/java/com/zhgd/xmgl/util/ExcelUtils.java @@ -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 teamList, List departmentList, List groupV2s) { try { XSSFWorkbook workbook = getExcelWorkerTemplateWorkbook(teamList, departmentList, groupV2s); diff --git a/src/main/java/com/zhgd/xmgl/util/HikVideoUtil.java b/src/main/java/com/zhgd/xmgl/util/HikVideoUtil.java index 81487918e..f77eb6051 100644 --- a/src/main/java/com/zhgd/xmgl/util/HikVideoUtil.java +++ b/src/main/java/com/zhgd/xmgl/util/HikVideoUtil.java @@ -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 paramMap = new HashMap();// 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)); diff --git a/src/main/java/com/zhgd/xmgl/util/TreeEntityUtil.java b/src/main/java/com/zhgd/xmgl/util/TreeEntityUtil.java new file mode 100644 index 000000000..35e99287c --- /dev/null +++ b/src/main/java/com/zhgd/xmgl/util/TreeEntityUtil.java @@ -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 + * @param + */ + public static > void updateTreeStructure( + T entity, + M mapper, + String sn, + Function> getChildrenFunction, + QuadConsumer 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 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 + */ + public static void addTreeStructure(T entity, BaseMapper 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()); + } + } + } +} diff --git a/src/main/resources/excel/执法记录仪导入模板.xlsx b/src/main/resources/excel/执法记录仪导入模板.xlsx new file mode 100644 index 000000000..a04b2b5db Binary files /dev/null and b/src/main/resources/excel/执法记录仪导入模板.xlsx differ