| | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Enumeration; |
| | | |
| | | /** |
| | | * Http帮助类 |
| | | * @author WWW |
| | | */ |
| | | @SuppressWarnings("ALL") |
| | | public class HttpHelper { |
| | | private final static String HTTP_SLASH2 = "://"; |
| | | |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * Word帮助类 |
| | | * @author WWW |
| | | */ |
| | | @SuppressWarnings("ALL") |
| | | public class WordHelper { |
| | | private final static Log log = LogFactory.getLog(WordHelper.class); |
| | | |
| | | /** |
| | | * 通过word模板生成word的主方法 |
| | | */ |
| | | public static void generateWord(String inputFile, String outPutFile, Map<String, String> insertTextMap, List<String[]> addList) { |
| | | FileInputStream inputStream = null; |
| | | FileOutputStream outputStream = null; |
| | |
| | | inputStream = new FileInputStream(inputFile); |
| | | outputStream = new FileOutputStream(outPutFile); |
| | | |
| | | // 获取docx解析对象 |
| | | XWPFDocument xwpfDocument = new XWPFDocument(inputStream); |
| | | |
| | | // 处理所有文段数据,除了表格 |
| | | if (null != insertTextMap && insertTextMap.size() > 0) { |
| | | handleParagraphs(xwpfDocument, insertTextMap); |
| | | } |
| | | |
| | | // 处理表格数据 |
| | | handleTable(xwpfDocument, insertTextMap, addList); |
| | | |
| | | // 写入数据 |
| | | xwpfDocument.write(outputStream); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理所有文段数据,除了表格 |
| | | */ |
| | | public static void handleParagraphs(XWPFDocument xwpfDocument, Map<String, String> insertTextMap) { |
| | | for (XWPFParagraph paragraph : xwpfDocument.getParagraphs()) { |
| | | String text = paragraph.getText(); |
| | | if (isReplacement(text)) { |
| | | for (XWPFRun run : paragraph.getRuns()) { |
| | | // 判断带有 ${} 的run |
| | | run.setText(matchesValue(run.text(), insertTextMap), 0); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理表格数据方法 |
| | | */ |
| | | public static void handleTable(XWPFDocument xwpfDocument, Map<String, String> map, List<String[]> addList) { |
| | | List<XWPFTable> tables = xwpfDocument.getTables(); |
| | | for (XWPFTable table : tables) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 替换数据 |
| | | */ |
| | | private static void replaceData(List<XWPFTableRow> rows, Map<String, String> map) { |
| | | for (XWPFTableRow row : rows) { |
| | | List<XWPFTableCell> tableCells = row.getTableCells(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 插入数据 |
| | | */ |
| | | private static void insertData(XWPFTable table, List<String[]> addList) { |
| | | for (int i = 1, c = addList.size(); i < c; i++) { |
| | | table.createRow(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置单元格文本 |
| | | */ |
| | | private static void setCellText(XWPFTableCell cell, String text) { |
| | | List<XWPFParagraph> paragraphs = cell.getParagraphs(); |
| | | for (XWPFParagraph paragraph : paragraphs) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 有${}的值匹配出替换的数据,没有${}就返回原来的数据 |
| | | * |
| | | * @param wordValue ${...} 带${}的变量 |
| | | * @param map 存储需要替换的数据 |
| | | * @return java.lang.String |
| | | */ |
| | | public static String matchesValue(String wordValue, Map<String, String> map) { |
| | | for (String s : map.keySet()) { |
| | | String s1 = "${" + s + "}"; |
| | |
| | | return wordValue; |
| | | } |
| | | |
| | | /** |
| | | * 测试是否包含需要替换的数据 |
| | | */ |
| | | public static boolean isReplacement(String text) { |
| | | return text.contains("$"); |
| | | } |
| | | |
| | | /** |
| | | * 复制模板行的属性 |
| | | */ |
| | | private static void setCellText(XWPFTableCell tmpCell, XWPFTableCell cell, String text) { |
| | | CTTc cttc2 = tmpCell.getCTTc(); |
| | | CTTcPr ctPr2 = cttc2.getTcPr(); |
| | |
| | | XWPFRun cellR = cellP.createRun(); |
| | | cellR.setText(text); |
| | | |
| | | // 复制字体信息 |
| | | copyFontInfo(cellR, tmpR); |
| | | |
| | | // 复制段落信息 |
| | | cellP.setAlignment(tmpP.getAlignment()); |
| | | cellP.setVerticalAlignment(tmpP.getVerticalAlignment()); |
| | | cellP.setBorderBetween(tmpP.getBorderBetween()); |
| | |
| | | CTPPr tmpPpr = tmpP.getCTP().getPPr(); |
| | | CTPPr cellPpr = cellP.getCTP().getPPr() != null ? cellP.getCTP().getPPr() : cellP.getCTP().addNewPPr(); |
| | | |
| | | // 复制段落间距信息 |
| | | copySpacing(tmpPpr, cellPpr); |
| | | |
| | | // 复制段落缩进信息 |
| | | copyParagraph(tmpPpr, cellPpr); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 复制字体信息 |
| | | */ |
| | | private static void copyFontInfo(XWPFRun cellR, XWPFRun tmpR) { |
| | | if (tmpR == null) { |
| | | return; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 复制段落间距信息 |
| | | */ |
| | | private static void copySpacing(CTPPr tmpPpr, CTPPr cellPpr) { |
| | | CTSpacing tmpSpacing = tmpPpr.getSpacing(); |
| | | if (tmpSpacing != null) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 复制段落缩进信息 |
| | | */ |
| | | private static void copyParagraph(CTPPr tmpPpr, CTPPr cellPpr) { |
| | | CTInd tmpInd = tmpPpr.getInd(); |
| | | if (tmpInd != null) { |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 图层 |
| | | * @author WWW |
| | | */ |
| | | @Mapper |
| | | @Repository |
| | | @SuppressWarnings("ALL") |
| | | public interface LayerMapper { |
| | | /** |
| | | * 根据用户ID查询图层列表 |
| | | * |
| | | * @param uid 用户ID |
| | | * @return 图层列表 |
| | | */ |
| | | public List<LayerEntity> selectLayers(String uid); |
| | | |
| | | /** |
| | | * 根据用户ID查询图投影层列表 |
| | | * |
| | | * @param uid 用户ID |
| | | * @return 投影图层列表 |
| | | */ |
| | | public List<LayerEntity> selectProjectLayers(String uid); |
| | | |
| | | /** |
| | | * 查询记录数 |
| | | * |
| | | * @param name 名称 |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCount(String name); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param name 名称 |
| | | * @param limit 记录数 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<LayerEntity> selectByPage(String name, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询所有 |
| | | * |
| | | * @param flag 图层标识 |
| | | * @return |
| | | */ |
| | | public List<LayerEntity> selectAll(Integer flag); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public LayerEntity selectById(int id); |
| | | |
| | | /** |
| | | * 根据名称查询ID |
| | | * |
| | | * @param name 名称 |
| | | * @return ID |
| | | */ |
| | | public Integer selectIdByName(String name); |
| | | |
| | | /** |
| | | * 根据pid查询最大排序数 |
| | | * |
| | | * @param pid 父类ID |
| | | * @return 最大排序数 |
| | | */ |
| | | public Integer selectMaxOrderNumByPid(Integer pid); |
| | | |
| | | /** |
| | | * 根据资源ID查询图层 |
| | | * |
| | | * @param resid 资源ID |
| | | * @return 图层 |
| | | */ |
| | | public LayerEntity selectByResId(Integer resid); |
| | | |
| | | /** |
| | | * 插入一条 |
| | | * |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | public Integer insert(LayerEntity entity); |
| | | |
| | | /** |
| | | * 插入多条 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public Integer inserts(List<LayerEntity> list); |
| | | |
| | | /** |
| | | * 删除一条 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public Integer delete(int id); |
| | | |
| | | /** |
| | | * 删除多条 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | public Integer deletes(List<Integer> ids); |
| | | |
| | | /** |
| | | * 更新一条 |
| | | * |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | public Integer update(LayerEntity entity); |
| | | |
| | | /** |
| | | * 更新多条 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public Integer updates(List<LayerEntity> list); |
| | | } |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 报告模板 |
| | | * @author WWW |
| | | */ |
| | | @Mapper |
| | | @Repository |
| | | @SuppressWarnings("ALL") |
| | | public interface ReportMapper { |
| | | /** |
| | | * 查询记录数 |
| | | * |
| | | * @param name 名称 |
| | | * @param code 编码 |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCount(String name, String code); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param name 名称 |
| | | * @param code 编码 |
| | | * @param limit 记录数 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<ReportEntity> selectByPage(String name, String code, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询所有 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<ReportEntity> selectAll(); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public ReportEntity selectById(int id); |
| | | |
| | | /** |
| | | * 插入一条 |
| | | * |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | public Integer insert(ReportEntity entity); |
| | | |
| | | /** |
| | | * 插入多条 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public Integer inserts(List<ReportEntity> list); |
| | | |
| | | /** |
| | | * 删除一条 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public Integer delete(int id); |
| | | |
| | | /** |
| | | * 删除多条 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | public Integer deletes(List<Integer> ids); |
| | | |
| | | /** |
| | | * 更新一条 |
| | | * |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | public Integer update(ReportEntity entity); |
| | | |
| | | /** |
| | | * 更新多条 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public Integer updates(List<ReportEntity> list); |
| | | |
| | | /** |
| | | * 数据量统计 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<CountEntity> countSizes(); |
| | | |
| | | /** |
| | | * 按文件类型统计 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<CountEntity> countSizesByType(); |
| | | |
| | | /** |
| | | * 服务调用量统计 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<CountEntity> countServices(); |
| | | |
| | | /** |
| | | * 用户流量统计 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<CountEntity> countOperates(); |
| | | |
| | | /** |
| | | * 按项目统计数据 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<CountEntity> countSizesByPrj(); |
| | | } |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 资源日志 |
| | | * @author WWW |
| | | */ |
| | | @Mapper |
| | | @Repository |
| | | @SuppressWarnings("ALL") |
| | | public interface ResLogMapper { |
| | | /** |
| | | * 查询记录数 |
| | | * |
| | | * @param resid 资源ID |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCount(Integer resid); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param resid 资源ID |
| | | * @param limit 记录数 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<ResLogEntity> selectByPage(Integer resid, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询所有 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<ResLogEntity> selectAll(); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public ResLogEntity selectById(int id); |
| | | |
| | | /** |
| | | * 插入一条 |
| | | * |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | public Integer insert(ResLogEntity entity); |
| | | |
| | | /** |
| | | * 插入多条 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public Integer inserts(List<ResLogEntity> list); |
| | | |
| | | /** |
| | | * 删除一条 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public Integer delete(int id); |
| | | |
| | | /** |
| | | * 删除多条 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | public Integer deletes(List<Integer> ids); |
| | | |
| | | /** |
| | | * 更新一条 |
| | | * |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | public Integer update(ResLogEntity entity); |
| | | |
| | | /** |
| | | * 更新多条 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public Integer updates(List<ResLogEntity> list); |
| | | } |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 资源 |
| | | * @author WWW |
| | | */ |
| | | @Mapper |
| | | @Repository |
| | | @SuppressWarnings("ALL") |
| | | public interface ResMapper { |
| | | /** |
| | | * 查询记录数 |
| | | * |
| | | * @param name 名称 |
| | | * @param status 状态 |
| | | * @param category 服务类别 |
| | | * @param type 服务类型 |
| | | * @param data 数据类型 |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCount(String name, Integer status, Integer category, Integer type, Integer data); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param name 名称 |
| | | * @param status 状态 |
| | | * @param category 服务类别 |
| | | * @param type 服务类型 |
| | | * @param data 数据类型 |
| | | * @param limit 记录数 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<ResEntity> selectByPage(String name, Integer status, Integer category, Integer type, Integer data, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询所有 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<ResEntity> selectAll(); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public ResEntity selectById(int id); |
| | | |
| | | /** |
| | | * 根据发布ID查询 |
| | | * |
| | | * @param pubid 发布ID |
| | | * @return |
| | | */ |
| | | public ResEntity selectByPubid(Integer pubid); |
| | | |
| | | /** |
| | | * 根据角色查询记录数 |
| | | * |
| | | * @param roleid |
| | | * @return |
| | | */ |
| | | public Integer selectCountForRole(Integer roleid); |
| | | |
| | | /** |
| | | * 根据角色分页查询 |
| | | * |
| | | * @param roleid |
| | | * @param limit |
| | | * @param offset |
| | | * @return |
| | | */ |
| | | public List<ResEntity> selectByPageForRole(Integer roleid, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 插入一条 |
| | | * |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | public Integer insert(ResEntity entity); |
| | | |
| | | /** |
| | | * 插入多条 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public Integer inserts(List<ResEntity> list); |
| | | |
| | | /** |
| | | * 删除一条 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public Integer delete(int id); |
| | | |
| | | /** |
| | | * 删除多条 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | public Integer deletes(String ids); |
| | | |
| | | /** |
| | | * 更新一条 |
| | | * |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | public Integer update(ResEntity entity); |
| | | |
| | | /** |
| | | * 更新多条 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public Integer updates(List<ResEntity> list); |
| | | } |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 角色-图层 |
| | | * @author WWW |
| | | */ |
| | | @Mapper |
| | | @Repository |
| | | @SuppressWarnings("ALL") |
| | | public interface RoleLayerMapper { |
| | | /** |
| | | * 根据角色查询图层 |
| | | * |
| | | * @param roleid 角色ID |
| | | * @return 列表 |
| | | */ |
| | | public List<RoleLayerEntity> selectLayersByRole(Integer roleid); |
| | | |
| | | /** |
| | | * 查询记录数 |
| | | * |
| | | * @param roleid 角色ID |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCount(Integer roleid); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param roleid 角色ID |
| | | * @param limit 记录数 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<RoleLayerEntity> selectByPage(Integer roleid, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询所有 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<RoleLayerEntity> selectAll(); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public RoleLayerEntity selectById(int id); |
| | | |
| | | /** |
| | | * 插入一条 |
| | | * |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | public Integer insert(RoleLayerEntity entity); |
| | | |
| | | /** |
| | | * 插入多条 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public Integer inserts(List<RoleLayerEntity> list); |
| | | |
| | | /** |
| | | * 删除一条 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public Integer delete(int id); |
| | | |
| | | /** |
| | | * 删除多条 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | public Integer deletes(List<Integer> ids); |
| | | |
| | | /** |
| | | * 更新一条 |
| | | * |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | public Integer update(RoleLayerEntity entity); |
| | | |
| | | /** |
| | | * 更新多条 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public Integer updates(List<RoleLayerEntity> list); |
| | | } |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 角色-资源 |
| | | * @author WWW |
| | | */ |
| | | @Mapper |
| | | @Repository |
| | | @SuppressWarnings("ALL") |
| | | public interface RoleResMapper { |
| | | /** |
| | | * 根据角色ID查询资源 |
| | | * |
| | | * @param roleid |
| | | * @return |
| | | */ |
| | | public List<RoleResEntity> selectResByRole(Integer roleid); |
| | | |
| | | /** |
| | | * 查询记录数 |
| | | * |
| | | * @param roleid 角色ID |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCount(Integer roleid); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param roleid 角色ID |
| | | * @param limit 记录数 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<RoleResEntity> selectByPage(Integer roleid, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询所有 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<RoleResEntity> selectAll(); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public RoleResEntity selectById(int id); |
| | | |
| | | /** |
| | | * 插入一条 |
| | | * |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | public Integer insert(RoleResEntity entity); |
| | | |
| | | /** |
| | | * 插入多条 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public Integer inserts(List<RoleResEntity> list); |
| | | |
| | | /** |
| | | * 删除一条 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public Integer delete(int id); |
| | | |
| | | /** |
| | | * 删除多条 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | public Integer deletes(List<Integer> ids); |
| | | |
| | | /** |
| | | * 更新一条 |
| | | * |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | public Integer update(RoleResEntity entity); |
| | | |
| | | /** |
| | | * 更新多条 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public Integer updates(List<RoleResEntity> list); |
| | | } |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 角色-用户 |
| | | * @author WWW |
| | | */ |
| | | @Mapper |
| | | @Repository |
| | | @SuppressWarnings("ALL") |
| | | public interface RoleUserMapper { |
| | | /** |
| | | * 查询记录数 |
| | | * |
| | | * @param roleid 角色ID |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCount(Integer roleid); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param roleid 角色ID |
| | | * @param limit 记录数 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<RoleUserEntity> selectByPage(Integer roleid, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询所有 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<RoleUserEntity> selectAll(); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public RoleUserEntity selectById(int id); |
| | | |
| | | /** |
| | | * 插入一条 |
| | | * |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | public Integer insert(RoleUserEntity entity); |
| | | |
| | | /** |
| | | * 插入多条 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public Integer inserts(List<RoleUserEntity> list); |
| | | |
| | | /** |
| | | * 删除一条 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public Integer delete(int id); |
| | | |
| | | /** |
| | | * 删除多条 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | public Integer deletes(List<Integer> ids); |
| | | |
| | | /** |
| | | * 更新一条 |
| | | * |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | public Integer update(RoleUserEntity entity); |
| | | |
| | | /** |
| | | * 更新多条 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public Integer updates(List<RoleUserEntity> list); |
| | | } |
| | |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * 父查询服务类 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class BaseQueryService implements BaseQueryMapper { |
| | | @Autowired |
| | | BaseQueryMapper baseQueryMapper; |
| | |
| | | @Autowired |
| | | RedisService redisService; |
| | | |
| | | /** |
| | | * 表名Map |
| | | */ |
| | | private static final Map<String, String> TAB_MAP = new HashMap<>(3); |
| | | |
| | | /** |
| | | * 添加过滤条件:(?i)and |
| | | * |
| | | * @param wrapper QueryWrapper |
| | | * @param filter 原始过滤条件字符串 |
| | | */ |
| | | public <T> void addFilterWrapper(QueryWrapper<T> wrapper, String filter) { |
| | | if (StringHelper.isEmpty(filter)) { |
| | | return; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 驼峰转换为下划线 |
| | | */ |
| | | public static String camelToUnderline(String str) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (int i = 0, c = str.length(); i < c; i++) { |
| | |
| | | return sb.toString().replaceAll("_+", "_"); |
| | | } |
| | | |
| | | /** |
| | | * 下划线转换为驼峰 |
| | | */ |
| | | public static String underlineToCamel(String str) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 获取值对象 |
| | | * |
| | | * @param val 值 |
| | | * @return 对象 |
| | | */ |
| | | private Object getObjectVal(String express, String val) { |
| | | if (StringHelper.isInteger(val)) { |
| | | return Long.parseLong(val); |
| | |
| | | return val.replace("'", ""); |
| | | } |
| | | |
| | | /** |
| | | * 添加包装器 |
| | | * |
| | | * @param wrapper QueryWrapper |
| | | * @param field 字段 |
| | | * @param express 表达式 |
| | | * @param val 值 |
| | | */ |
| | | private <T> void addWrapper(QueryWrapper<T> wrapper, String field, String express, Object val) { |
| | | if (StringHelper.isDate(val.toString())) { |
| | | wrapper.apply(String.format("%s %s '%s'", field, express, val)); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取字符串列表 |
| | | */ |
| | | private List<String> getStringList(String val) { |
| | | return Arrays.asList(val.replace(StaticData.SINGLE_QUOTES, "").split(StaticData.COMMA)); |
| | | } |
| | | |
| | | /** |
| | | * 获取整数列表 |
| | | */ |
| | | private List<Integer> getIntegerList(String val) { |
| | | List<Integer> list = new ArrayList<>(); |
| | | for (String str : val.split(StaticData.COMMA)) { |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 添加空间过滤条件 |
| | | * |
| | | * @param basicMapper 父Mapper |
| | | * @param wrapper QueryWrapper |
| | | * @param wkt WKT(著名文本) |
| | | * @throws Exception 异常 |
| | | */ |
| | | public void addGeomWrapper(BasicMapper basicMapper, QueryWrapper wrapper, String wkt) throws Exception { |
| | | if (basicMapper instanceof GeomBaseMapper && !StringHelper.isEmpty(wkt)) { |
| | | wkt = AesHelper.decrypt(wkt); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取几何对象的空间参考 |
| | | * |
| | | * @param basicMapper 空间基础Mapper |
| | | * @return SRID |
| | | */ |
| | | public Integer getSrid(GeomBaseMapper basicMapper) { |
| | | String tab = getTabName(basicMapper); |
| | | String key = RedisCacheKey.sridKey(tab); |
| | |
| | | return srid; |
| | | } |
| | | |
| | | /** |
| | | * 根据Mapper获取表名 |
| | | * |
| | | * @param basicMapper Mapper |
| | | * @return 表名 |
| | | */ |
| | | public static String getTabName(BasicMapper basicMapper) { |
| | | String className = ClassHelper.getClassName(basicMapper); |
| | | if (TAB_MAP.containsKey(className)) { |
| | |
| | | return getTabName(className); |
| | | } |
| | | |
| | | /** |
| | | * 根据Mapper获取表名 |
| | | * |
| | | * @param className Mapper类名 |
| | | * @return 表名 |
| | | */ |
| | | private static String getTabName(String className) { |
| | | Class clazz = ClassHelper.getEntityClass(className); |
| | | if (clazz == null) { |
| | |
| | | return tabName; |
| | | } |
| | | |
| | | /** |
| | | * 添加缓冲区过滤条件 |
| | | * |
| | | * @param baseMapper 父Mapper |
| | | * @param wrapper QueryWrapper |
| | | * @param wkt WKT(著名文本) |
| | | */ |
| | | public void addBufferWrapper(GeomBaseMapper baseMapper, QueryWrapper wrapper, String wkt, double buffer) { |
| | | Integer srid = getSrid(baseMapper); |
| | | // buffer = buffer * 0.00000899928 |
| | |
| | | import java.sql.Timestamp; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 父上传服务 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class BaseUploadService { |
| | | @Autowired |
| | | protected DirService dirService; |
| | |
| | | |
| | | public final Log log = LogFactory.getLog(getClass()); |
| | | |
| | | /** |
| | | * 查询目录 |
| | | */ |
| | | public String selectPath() { |
| | | return pathHelper.getTempPathName(); |
| | | } |
| | | |
| | | /** |
| | | * 上传文件 |
| | | */ |
| | | public <T> List<MetaFileEntity> uploadData(T t, String path, boolean isGetGuid, HttpServletRequest req, HttpServletResponse res) throws Exception { |
| | | StandardMultipartHttpServletRequest request = (StandardMultipartHttpServletRequest) req; |
| | | req.setCharacterEncoding("utf-8"); |
| | |
| | | return getFiles(path, isGetGuid, request); |
| | | } |
| | | |
| | | /** |
| | | * 设置实体类 |
| | | */ |
| | | private <T> void setEntity(T t, StandardMultipartHttpServletRequest req) { |
| | | Enumeration<String> enumeration = req.getParameterNames(); |
| | | while (enumeration.hasMoreElements()) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取文件 |
| | | */ |
| | | public List<MetaFileEntity> getFiles(String subPath, boolean isGetGuid, StandardMultipartHttpServletRequest req) throws Exception { |
| | | List<MetaFileEntity> list = new ArrayList<>(); |
| | | |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 查询文件 |
| | | */ |
| | | public List<MetaFileEntity> selectFiles(String subPath, boolean hasMd5) { |
| | | String root = pathHelper.getConfig().getTempPath() + File.separator + subPath; |
| | | |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 删除文件 |
| | | */ |
| | | public Integer deleteFiles(List<MetaFileEntity> list) { |
| | | String root = pathHelper.getConfig().getTempPath(); |
| | | |
| | |
| | | return count; |
| | | } |
| | | |
| | | /** |
| | | * 查询映射 |
| | | */ |
| | | public List<MetaFileEntity> selectMappers(UserEntity ue, String path, DirEntity dir, VerEntity ver) { |
| | | List<MetaFileEntity> metas = selectFiles(path, true); |
| | | if (null == metas || metas.isEmpty()) { |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取映射文件 |
| | | */ |
| | | private List<MetaFileEntity> getMapperFiles(String path, DirEntity dir, List<DirEntity> dirs, MetaFileEntity meta) { |
| | | String tempPath = pathHelper.getConfig().getTempPath(); |
| | | String zipFile = tempPath + File.separator + meta.getPath(); |
| | |
| | | return getMapperFiles(files, dir, dirs, meta, tempPath.length() + 1); |
| | | } |
| | | |
| | | /** |
| | | * 根据路径获取文件 |
| | | */ |
| | | private void getFilesByPath(List<File> list, String path) { |
| | | File file = new File(path); |
| | | if (!file.isDirectory()) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 文件是/否有效 |
| | | */ |
| | | private boolean isFileValid(String fileName) { |
| | | String extName = FileHelper.getExtension(fileName); |
| | | if (fileName.startsWith(StaticData.TILDE) || !StaticData.ALL_EXTENSION.contains(extName)) { |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 获取映射文件 |
| | | */ |
| | | private List<MetaFileEntity> getMapperFiles(List<File> files, DirEntity dir, List<DirEntity> dirs, MetaFileEntity meta, int start) { |
| | | List<MetaFileEntity> list = new ArrayList<>(); |
| | | for (File f : files) { |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 创建元数据文件实体类 |
| | | */ |
| | | private MetaFileEntity createMetaFileEntity(File f, MetaFileEntity meta, String fileName, String extName) { |
| | | boolean isShp = StaticData.SHP.equals(extName); |
| | | |
| | |
| | | return mf; |
| | | } |
| | | |
| | | /** |
| | | * 创建元数据文件实体类 |
| | | */ |
| | | private MetaFileEntity createMetaFileEntity(MetaFileEntity meta) { |
| | | MetaFileEntity mf = new MetaFileEntity(); |
| | | mf.setDircode(meta.getDircode()); |
| | |
| | | return mf; |
| | | } |
| | | |
| | | /** |
| | | * 根据文件路径获取目录ID |
| | | */ |
| | | private String getDirByPath(String filePath,String fileName, DirEntity dir, List<DirEntity> dirs) { |
| | | if (0 != dir.getPid() || null == dirs || dirs.isEmpty()) { |
| | | return dir.getCode(); |
| | |
| | | return dir.getCode(); |
| | | } |
| | | |
| | | /** |
| | | * 获取SHP文件集合 |
| | | */ |
| | | private List<String> getShpFiles(String shpPath) { |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(shpPath); |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取GDB文件集合 |
| | | */ |
| | | private List<String> getGdbFiles(String path) { |
| | | List<String> list = new ArrayList<>(); |
| | | |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取多文件的MD5 |
| | | */ |
| | | private String getFilesMd5(List<String> files) { |
| | | List<String> list = new ArrayList<>(); |
| | | for (String file : files) { |
| | |
| | | return StringHelper.getGuid(); |
| | | } |
| | | |
| | | /** |
| | | * 获取多文件的大小 |
| | | */ |
| | | private double getFilesSize(List<String> files) { |
| | | long size = 0L; |
| | | for (String file : files) { |
| | |
| | | return FileHelper.sizeToMb(size); |
| | | } |
| | | |
| | | /** |
| | | * 获取GDB文件映射 |
| | | */ |
| | | private List<MetaFileEntity> getGdbMappers(File f, MetaFileEntity meta, String dircode, int start) { |
| | | List<String> tabs = GdbHelper.getTabNames(f.getPath()); |
| | | if (null == tabs || tabs.size() == 0) { |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 是/否为GDB文件 |
| | | */ |
| | | private boolean isGdbFile(File f) { |
| | | if (f.isDirectory() && f.getName().toLowerCase().endsWith(StaticData.GDB)) { |
| | | File gdb = new File(f.getPath() + File.separator + "gdb"); |
| | |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 设置元数据文件的类型 |
| | | */ |
| | | private void setMetaType(List<MetaFileEntity> list) { |
| | | for (MetaFileEntity mf : list) { |
| | | if (null != mf.getExtName()) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理目录 |
| | | */ |
| | | public void copePath(List<MetaFileEntity> list) { |
| | | String basePath = pathHelper.getConfig().getTempPath() + File.separator; |
| | | for (MetaFileEntity mf : list) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 是/否为OSGB文件 |
| | | */ |
| | | private boolean isOsgbFile(File f) { |
| | | if (f.isDirectory()) { |
| | | File meta = new File(f.getPath() + File.separator + "metadata.xml"); |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取OSGB文件映射 |
| | | */ |
| | | private MetaFileEntity getOsgbMapper(File f, MetaFileEntity meta, String dircode, int start) { |
| | | String fileName = FileHelper.getFileName(f.getPath()); |
| | | |
| | |
| | | return mf; |
| | | } |
| | | |
| | | /** |
| | | * 获取参数 * |
| | | * Enumeration<String> headers = req.getHeaderNames(); |
| | | * Enumeration<String> attributes = req.getAttributeNames(); |
| | | */ |
| | | public Map<String, String> getParams(StandardMultipartHttpServletRequest req) { |
| | | Map<String, String> map = new HashMap<>(3); |
| | | |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * CommonsFileupload上传服务 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class CommonsFileuploadService { |
| | | @Autowired |
| | | PathHelper pathHelper; |
| | |
| | | return copeFileItems(items, req); |
| | | } |
| | | |
| | | /** |
| | | * 获取文件项 |
| | | */ |
| | | private List<FileItem> getFileItem(HttpServletRequest req, HttpServletResponse res) throws Exception { |
| | | // 处理中文乱码问题 |
| | | req.setCharacterEncoding("utf-8"); |
| | | // text/html;charset=utf-8 |
| | | res.setContentType("application/json;charset=utf-8"); |
| | | |
| | | // 检查请求是/否为multipart/form-data类型 |
| | | if (!ServletFileUpload.isMultipartContent(req)) { |
| | | throw new RuntimeException("表单的enctype属性不是multipart/form-data类型"); |
| | | } |
| | | |
| | | // 创建上传所需要的两个对象:磁盘文件对象+文件上传对象 |
| | | DiskFileItemFactory factory = new DiskFileItemFactory(); |
| | | ServletFileUpload sfu = new ServletFileUpload(factory); |
| | | ServletRequestContext ctx = new ServletRequestContext(req); |
| | | |
| | | // 设置编码方式 |
| | | sfu.setHeaderEncoding("utf-8"); |
| | | factory.setSizeThreshold(4096); |
| | | |
| | | // 获取表单中的所有数据信息 |
| | | List<FileItem> list = sfu.parseRequest(ctx); |
| | | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 处理解析内容:处理普通表单域和文件表单域 |
| | | */ |
| | | private Object copeFileItems(List<FileItem> items, HttpServletRequest req) throws Exception { |
| | | Map<String, String> map = new HashMap<String, String>(3); |
| | | List<FileInfoEntity> list = new ArrayList<FileInfoEntity>(); |
| | |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 处理文件 |
| | | */ |
| | | private FileInfoEntity copeFile(FileItem item, String path, HttpServletRequest req) { |
| | | try { |
| | | // 获取文件名,判断是否合法 |
| | | FileInfoEntity fi = new FileInfoEntity(item.getName()); |
| | | if (StringHelper.isEmpty(fi.getFileName())) { |
| | | return null; |
| | |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * 授权服务 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class PermsService implements PermsMapper { |
| | | @Resource |
| | | PermsMapper permsMapper; |
| | |
| | | return permsMapper.selectMenuRecursive(id, uid); |
| | | } |
| | | |
| | | /** |
| | | * 清除资源缓存 |
| | | */ |
| | | public void clearResCache() { |
| | | redisService.clearKeys(RedisCacheKey.permsResKey("")); |
| | | } |
| | | |
| | | /** |
| | | * 清除图层缓存 |
| | | */ |
| | | public void clearLayerCache() { |
| | | redisService.clearKeys(RedisCacheKey.permsLayerKey("")); |
| | | } |
| | | |
| | | /** |
| | | * 清除授权缓存 |
| | | */ |
| | | public void clearPermsCache() { |
| | | redisService.clearKeys(RedisCacheKey.permsRootKey()); |
| | | } |
| | | |
| | | /** |
| | | * 清除所有缓存 |
| | | */ |
| | | public void clearAllCache() { |
| | | redisService.clearAll(); |
| | | } |
| | |
| | | import java.util.Set; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * Redis服务类 |
| | | * @author WWW |
| | | */ |
| | | @Service("redisService") |
| | | @SuppressWarnings("ALL") |
| | | public class RedisService { |
| | | @Autowired |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | /** |
| | | * 获取Redis模板 |
| | | * |
| | | * @return |
| | | */ |
| | | public RedisTemplate<String, Object> getRedisTemplate() { |
| | | return redisTemplate; |
| | | } |
| | | |
| | | /** |
| | | * 设置值到redis中 |
| | | * |
| | | * @param key 键 |
| | | * @param value 值 |
| | | */ |
| | | |
| | | public void put(String key, Object value) { |
| | | redisTemplate.opsForValue().set(key, value); |
| | | } |
| | | |
| | | /** |
| | | * 设置值到redis中,并设置过期时间 |
| | | * |
| | | * @param key 键 |
| | | * @param value 值 |
| | | * @param timeout 时间 |
| | | * @param unit 单位 |
| | | */ |
| | | public void put(String key, Object value, long timeout, TimeUnit unit) { |
| | | redisTemplate.opsForValue().set(key, value, timeout, unit); |
| | | } |
| | | |
| | | /** |
| | | * 根据key获取value |
| | | * |
| | | * @param key 键 |
| | | * @return |
| | | */ |
| | | public Object get(String key) { |
| | | return redisTemplate.opsForValue().get(key); |
| | | } |
| | | |
| | | /** |
| | | * 是否存在key |
| | | * |
| | | * @param key 键 |
| | | * @return |
| | | */ |
| | | public boolean hasKey(String key) { |
| | | return redisTemplate.hasKey(key); |
| | | } |
| | | |
| | | /** |
| | | * 移除key |
| | | * |
| | | * @param key 键 |
| | | */ |
| | | public void delete(String key) { |
| | | if (hasKey(key)) { |
| | | redisTemplate.delete(key); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 清空指定键前缀 |
| | | * |
| | | * @param subKeyString 键前缀 |
| | | */ |
| | | public void clearKeys(String subKeyString) { |
| | | Set<String> keys = redisTemplate.keys(subKeyString + "*"); |
| | | if (null != keys && keys.size() > 0) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 清空所有 |
| | | */ |
| | | public void clearAll() { |
| | | Set<String> keys = redisTemplate.keys("*"); |
| | | if (null != keys && keys.size() > 0) { |
| | |
| | | import oshi.hardware.CentralProcessor; |
| | | import oshi.hardware.GlobalMemory; |
| | | |
| | | /** |
| | | * 日程服务类 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class ScheduleService { |
| | | @Autowired |
| | | private ResService resService; |
| | |
| | | |
| | | private static final Log log = LogFactory.getLog(ScheduleService.class); |
| | | |
| | | /** |
| | | * 查询服务器状态 |
| | | */ |
| | | public JSONObject selectServerStatus() throws InterruptedException { |
| | | JSONObject json = new JSONObject(); |
| | | json.put("cpuInfo", selectCpuInfo()); |
| | |
| | | return json; |
| | | } |
| | | |
| | | /** |
| | | * 查询Cpu信息 |
| | | */ |
| | | public JSONObject selectCpuInfo() throws InterruptedException { |
| | | SystemInfo systemInfo = new SystemInfo(); |
| | | CentralProcessor processor = systemInfo.getHardware().getProcessor(); |
| | | long[] prevTicks = processor.getSystemCpuLoadTicks(); |
| | | |
| | | // 睡眠1s |
| | | TimeUnit.SECONDS.sleep(1); |
| | | long[] ticks = processor.getSystemCpuLoadTicks(); |
| | | long nice = ticks[CentralProcessor.TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()]; |
| | |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 查询内存信息 |
| | | */ |
| | | public JSONObject selectMemInfo() { |
| | | JSONObject map = new JSONObject(); |
| | | SystemInfo systemInfo = new SystemInfo(); |
| | | GlobalMemory memory = systemInfo.getHardware().getMemory(); |
| | | |
| | | // 总内存 |
| | | long totalByte = memory.getTotal(); |
| | | |
| | | // 剩余 |
| | | long surplusByte = memory.getAvailable(); |
| | | map.put("totalMem", FileHelper.formatByte(totalByte)); |
| | | map.put("use", FileHelper.formatByte(totalByte - surplusByte)); |
| | |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 查询在线用户 |
| | | */ |
| | | public List<JSONObject> selectOnlineUsers() { |
| | | List<JSONObject> list = new ArrayList<JSONObject>(); |
| | | |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 统计在线用户数 |
| | | */ |
| | | public int countOnlineUsers() { |
| | | Set<String> keys = redisTemplate.keys(RedisCacheKey.signUserKey("*")); |
| | | |
| | | return null == keys ? 0 : keys.size(); |
| | | } |
| | | |
| | | /** |
| | | * 查询服务资源状态 |
| | | */ |
| | | public List<ResEntity> selectResStatus() { |
| | | List<ResEntity> resList = resService.selectAll(); |
| | | |
| | | return testResStatus(resList); |
| | | } |
| | | |
| | | /** |
| | | * 测试资源状态 |
| | | */ |
| | | private List<ResEntity> testResStatus(List<ResEntity> resList) { |
| | | List<ResEntity> list = new ArrayList<>(); |
| | | for (ResEntity re : resList) { |
| | |
| | | URI uri = new URI(re.getUrl()); |
| | | SocketAddress add = new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()); |
| | | |
| | | // Ping通地址 |
| | | socket.connect(add, 2000); |
| | | } catch (Exception e) { |
| | | // log.error(e.getMessage()) |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 统计服务资源状态 |
| | | */ |
| | | public JSONObject countResStatus() { |
| | | List<ResEntity> resList = resService.selectAll(); |
| | | List<ResEntity> unableList = testResStatus(resList); |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | |
| | | // 资源可用 |
| | | jsonObject.put("resAbleCount", resList.size() - unableList.size()); |
| | | // 资源不可用 |
| | | jsonObject.put("resUnableCount", unableList.size()); |
| | | |
| | | return jsonObject; |
| | | } |
| | | |
| | | /** |
| | | * 资源操作状态 |
| | | */ |
| | | public JSONObject operateCount() { |
| | | List<OperateEntity> list = operateService.operateCount(); |
| | | JSONObject jsonObject = new JSONObject(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 用户登录状态 |
| | | */ |
| | | public JSONObject userLoginCount() { |
| | | List<LoginEntity> list = loginService.selectLoginCounts(); |
| | | if (list == null || list.isEmpty()) { |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 签名服务类 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class SignService { |
| | | @Autowired |
| | | PropertiesConfig propertiesConfig; |
| | | |
| | | private final static String SUCCESS = "success"; |
| | | |
| | | /** |
| | | * 自动登录Druid |
| | | */ |
| | | public void loginDruid(HttpServletRequest req, HttpServletResponse res) throws Exception { |
| | | List<NameValuePair> list = new ArrayList<>(); |
| | | list.add(new BasicNameValuePair("loginUsername", propertiesConfig.getDruidUser())); |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 系统服务类 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class SysService { |
| | | @Autowired |
| | | public TokenService tokenService; |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 测试服务类 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("AlibabaRemoveCommentedCode") |
| | | public class TestService { |
| | |
| | | import java.lang.reflect.Field; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 上传附件服务类 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class UploadAttachService { |
| | | @Autowired |
| | | PathHelper pathHelper; |
| | |
| | | |
| | | private final static Log log = LogFactory.getLog(UploadAttachService.class); |
| | | |
| | | /** |
| | | * 获取表名 |
| | | */ |
| | | public static String getTabs() { |
| | | return tabs; |
| | | } |
| | | |
| | | /** |
| | | * 初始化附件表 |
| | | */ |
| | | public static void init(String cfg) { |
| | | if (StringHelper.isEmpty(cfg)) { |
| | | return; |
| | |
| | | tabs = StringHelper.join(keys, ","); |
| | | } |
| | | |
| | | /** |
| | | * 上传文件 |
| | | */ |
| | | public ResponseMsg<String> upload(UserEntity ue, String tab, MultipartFile file, BaseController ctrl) { |
| | | try { |
| | | if (file == null && file.isEmpty()) { |
| | |
| | | return ctrl.fail(String.format("文件大于 %d MB", SettingData.MAX_FILE_SIZE / 1024 / 1024), null); |
| | | } |
| | | |
| | | // 传输文件 |
| | | String oldName = file.getOriginalFilename(); |
| | | String filePath = pathHelper.getTempPath() + File.separator + oldName; |
| | | File newFile = new File(filePath); |
| | | file.transferTo(newFile); |
| | | double sizes = FileHelper.sizeToMb(file.getSize()); |
| | | |
| | | // 获取MD5 |
| | | String md5 = FileHelper.getFileMd5(filePath); |
| | | AttachEntity entity = attachService.selectByGuid(md5); |
| | | if (entity != null) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取附件实体类 |
| | | */ |
| | | protected AttachEntity getAttachEntity(UserEntity ue, String tab, String oldName, String md5, double sizes) { |
| | | AttachEntity entity = new AttachEntity(); |
| | | entity.setName(oldName); |
| | |
| | | return entity; |
| | | } |
| | | |
| | | /** |
| | | * 下载文件 |
| | | */ |
| | | public void download(String guid, HttpServletResponse res) { |
| | | download(guid, false, res); |
| | | } |
| | | |
| | | /** |
| | | * 下载文件 |
| | | */ |
| | | public void download(String guid, boolean inline, HttpServletResponse res) { |
| | | try { |
| | | if (StringHelper.isEmpty(guid)) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 上传Excel附件 |
| | | */ |
| | | public List<KeyValueEntity> uploadXlsAnnex(UserEntity ue, List<MetaEntity> ms, List<MetaFileEntity> list, String path) { |
| | | List<String> files = getAttachFiles(list, path); |
| | | if (files.size() == 0) { |
| | |
| | | return rs; |
| | | } |
| | | |
| | | /** |
| | | * 获取附件文件 |
| | | */ |
| | | private List<String> getAttachFiles(List<MetaFileEntity> list, String path) { |
| | | List<String> files = new ArrayList<>(); |
| | | |
| | |
| | | return files; |
| | | } |
| | | |
| | | /** |
| | | * 获取zip中的文件 |
| | | */ |
| | | private List<String> getZipFiles(MetaFileEntity mf, String path) { |
| | | File file = new File(mf.getPath()); |
| | | if (!file.exists() || file.isDirectory()) { |
| | |
| | | return files; |
| | | } |
| | | |
| | | /** |
| | | * 根据路径获取文件 |
| | | */ |
| | | private void getFilesByPath(List<String> list, String path) { |
| | | File file = new File(path); |
| | | if (!file.isDirectory()) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 上传Excel附件 |
| | | */ |
| | | private int uploadXlsAnnex(UserEntity ue, MetaEntity meta, List<String> files) { |
| | | List<?> list = queryXlsData(meta); |
| | | if (null == list || list.size() == 0) { |
| | |
| | | return rows; |
| | | } |
| | | |
| | | /** |
| | | * 获取名称 |
| | | */ |
| | | public static String[] getNames(String str) { |
| | | if (StringHelper.isEmpty(str)) { |
| | | return null; |
| | |
| | | return str.replace(";", ",").replace(",", ",").split(","); |
| | | } |
| | | |
| | | /** |
| | | * 查询Excel数据 |
| | | */ |
| | | private List<?> queryXlsData(MetaEntity meta) { |
| | | String entity = meta.getTab().substring(meta.getTab().indexOf(".") + 1).replace("_", "").toLowerCase(); |
| | | BasicMapper basicMapper = ClassHelper.getBasicMapper(entity); |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取附件字段 |
| | | */ |
| | | public static Field getAnnexField(Object obj, String tab) { |
| | | try { |
| | | String str = ATTACH_TABS.get(tab); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取附件名称 |
| | | */ |
| | | public static String getAnnexName(Object obj, Field field) { |
| | | try { |
| | | Object val = field.get(obj); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查找附件文件 |
| | | */ |
| | | private String findAnnexFile(String name, String folder, List<String> files) { |
| | | name = File.separator + name.split("\\.")[0].trim().toLowerCase(); |
| | | for (String file : files) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 插入Excel附件 |
| | | */ |
| | | private int insertXlsAnnex(UserEntity ue, MetaEntity meta, BaseEntity be, String file) { |
| | | File f = new File(file); |
| | | if (!f.exists() || f.isDirectory()) { |
| | |
| | | return attachService.insert(ae); |
| | | } |
| | | |
| | | /** |
| | | * 获取附件实体类 |
| | | */ |
| | | protected AttachEntity getAttachEntity(UserEntity ue, String tabName, String eventid, String fileName, String md5, double sizes) { |
| | | AttachEntity entity = new AttachEntity(); |
| | | entity.setTab(tabName); |
| | |
| | | return entity; |
| | | } |
| | | |
| | | /** |
| | | * 请求下载 |
| | | */ |
| | | public String downloadReqForGuids(UserEntity ue, List<String> guids) { |
| | | List<AttachEntity> list = attachService.selectByGuids(guids); |
| | | |
| | | return downloadReq(ue, list); |
| | | } |
| | | |
| | | /** |
| | | * 请求下载 |
| | | */ |
| | | public String downloadReqForTabGuids(UserEntity ue, String tab, List<String> guids) { |
| | | List<AttachEntity> list = attachService.selectByTabGuids(tab, guids); |
| | | |
| | | return downloadReq(ue, list); |
| | | } |
| | | |
| | | /** |
| | | * 请求下载 |
| | | */ |
| | | protected String downloadReq(UserEntity ue, List<AttachEntity> list) { |
| | | if (null == list || list.isEmpty()) { |
| | | return null; |
| | |
| | | return rows > 0 ? downloadEntity.getGuid() : null; |
| | | } |
| | | |
| | | /** |
| | | * 添加Zip文件 |
| | | */ |
| | | private void addZipFiles(ZipFile zip, ZipParameters params, List<AttachEntity> list) { |
| | | int i = 1; |
| | | String uploadPath = pathHelper.getConfig().getUploadPath(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取下载实体类 |
| | | */ |
| | | private DownloadEntity getDownloadEntity(UserEntity ue, String file, String pwd) { |
| | | DownloadEntity de = new DownloadEntity(); |
| | | de.setName(FileHelper.getFileName(file)); |
| | |
| | | import java.util.concurrent.CopyOnWriteArraySet; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | /** |
| | | * WebSocket服务类 |
| | | * @author WWW |
| | | */ |
| | | @ServerEndpoint(value = "/ws/select") |
| | | @Component |
| | | @SuppressWarnings("ALL") |
| | | @ServerEndpoint(value = "/ws/select") |
| | | public class WebSocketService { |
| | | @PostConstruct |
| | | public void init() { |
| | |
| | | |
| | | private static final AtomicInteger ONLINE_COUNT = new AtomicInteger(0); |
| | | |
| | | /** |
| | | * 用来存放每个客户端对应的Session对象(线程安全Set) |
| | | */ |
| | | private final static CopyOnWriteArraySet<Session> SESSION_SET = new CopyOnWriteArraySet<Session>(); |
| | | |
| | | /** |
| | | * 连接建立成功调用的方法 |
| | | */ |
| | | @OnOpen |
| | | public void onOpen(Session session) { |
| | | SESSION_SET.add(session); |
| | |
| | | sendMessage(session, "连接成功"); |
| | | } |
| | | |
| | | /** |
| | | * 连接关闭调用的方法 |
| | | */ |
| | | @OnClose |
| | | public void onClose(Session session) { |
| | | SESSION_SET.remove(session); |
| | |
| | | log.info("有连接关闭,当前连接数为:{}", cnt); |
| | | } |
| | | |
| | | /** |
| | | * 收到客户端消息后调用的方法 |
| | | * |
| | | * @param message 客户端发送过来的消息 |
| | | */ |
| | | @OnMessage |
| | | public void onMessage(String message, Session session) { |
| | | log.info("来自客户端的消息:{}", message); |
| | | sendMessage(session, "收到消息,消息内容:" + message); |
| | | } |
| | | |
| | | /** |
| | | * 出现错误 |
| | | */ |
| | | @OnError |
| | | public void onError(Session session, Throwable error) { |
| | | log.error("发生错误:{},Session ID: {}", error.getMessage(), session.getId()); |
| | | } |
| | | |
| | | /** |
| | | * 发送消息,实践表明,每次浏览器刷新,session会发生变化。 |
| | | */ |
| | | public static void sendMessage(Session session, String message) { |
| | | try { |
| | | // session.getAsyncRemote().sendText(message) |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 群发消息 |
| | | */ |
| | | public static void broadCastInfo(String message) throws IOException { |
| | | for (Session session : SESSION_SET) { |
| | | if (session.isOpen()) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 指定Session发送消息 |
| | | */ |
| | | public static void sendMessage(String message, String sessionId) throws IOException { |
| | | Session session = null; |
| | | for (Session s : SESSION_SET) { |
| | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 颜色 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class ColortabService implements ColortabMapper { |
| | | @Resource |
| | | ColortabMapper colortabMapper; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 数据检索服务 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class DataQueryService { |
| | | @Autowired |
| | | PathHelper pathHelper; |
| | |
| | | @Autowired |
| | | AttachService attachService; |
| | | |
| | | /** |
| | | * 上传文件 |
| | | */ |
| | | public Integer uploadFiles(UserEntity ue, String tabName, String eventid, MultipartFile[] files, HttpServletRequest req) throws IOException { |
| | | List<AttachEntity> list = new ArrayList<AttachEntity>(); |
| | | for (MultipartFile file : files) { |
| | |
| | | continue; |
| | | } |
| | | |
| | | // 传输文件 |
| | | String fileName = file.getOriginalFilename(); |
| | | String filePath = pathHelper.getTempPath() + File.separator + fileName; |
| | | File newFile = new File(filePath); |
| | | file.transferTo(newFile); |
| | | double sizes = FileHelper.sizeToMb(file.getSize()); |
| | | |
| | | // 获取MD5 |
| | | String md5 = FileHelper.getFileMd5(filePath); |
| | | AttachEntity entity = attachService.selectByGuid(md5); |
| | | |
| | |
| | | return attachService.inserts(list); |
| | | } |
| | | |
| | | /** |
| | | * 获取附件实体类 |
| | | */ |
| | | protected AttachEntity getAttachEntity(UserEntity ue, String tabName, String eventid, String fileName, String md5, double sizes) { |
| | | AttachEntity entity = new AttachEntity(); |
| | | entity.setTab(tabName); |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 字典 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class DictService implements DictMapper { |
| | | @Autowired |
| | | DictMapper dictMapper; |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 值域 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class DomainService implements DomainMapper { |
| | | @Autowired |
| | | DomainMapper domainMapper; |
| | |
| | | import java.io.File; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 下载记录 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class DownloadService implements DownloadMapper { |
| | | @Autowired |
| | | PathHelper pathHelper; |
| | |
| | | return downloadMapper.updates(list); |
| | | } |
| | | |
| | | /** |
| | | * 获取下载文件路径 |
| | | * |
| | | * @param de 下载实体类 |
| | | * @return 下载文件路径 |
| | | */ |
| | | public String getDownloadFilePath(DownloadEntity de) { |
| | | return pathHelper.getConfig().getDownloadPath() + File.separator + de.getUrl(); |
| | | } |
| | | |
| | | /** |
| | | * 解密 |
| | | * |
| | | * @param entity 密码抽象类 |
| | | * @return 是/否解密成功 |
| | | */ |
| | | public static boolean decryptPwd(AbstractPwdEntity entity) { |
| | | try { |
| | | String pwd = RsaHelper.decrypt(entity.getPwd()); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 解密 |
| | | * |
| | | * @param pe 管道分析实体类 |
| | | * @return 是/否解密成功 |
| | | */ |
| | | public static boolean decryptPwd(PipelineEntity pe) { |
| | | try { |
| | | String pwd = RsaHelper.decrypt(pe.getPwd()); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 解密 |
| | | * |
| | | * @param pwd 加密密码 |
| | | * @return 原始密码 |
| | | */ |
| | | public static String decryptPwd(String pwd) { |
| | | try { |
| | | return RsaHelper.decrypt(pwd); |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * FME服务类 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class FmeService { |
| | | @Value("${sys.fmeUrl}") |
| | | private String fmeUrl; |
| | | |
| | | /** |
| | | * 获取任务状态 |
| | | */ |
| | | public Object getTaskStatus(String id, HttpServletRequest req) { |
| | | String url = getUrl("datax/task/get", req) + "&id=" + id; |
| | | |
| | | return RestHelper.getForRest(url, Object.class); |
| | | } |
| | | |
| | | /** |
| | | * 下载质检错误结果 |
| | | */ |
| | | public String getDownloadUrl(String id, HttpServletRequest req) { |
| | | return getUrl("datax/task/downloadResult", req) + "&id=" + id; |
| | | } |
| | | |
| | | /** |
| | | * 1.OSGB检查:.osgb + *倾斜摄影*.xls/.xlsx |
| | | */ |
| | | public String checkOsgb(FmeReqEntity fme, HttpServletRequest req) { |
| | | String url = getUrl("datax/task/run/A8成果质检_OSGB检查", req); |
| | | |
| | |
| | | return RestHelper.postForRest(url, list); |
| | | } |
| | | |
| | | /** |
| | | * 2.表格数据检查:.xls/.xlsx(排除元数据) |
| | | */ |
| | | public String checkXls(FmeReqEntity fme, HttpServletRequest req) { |
| | | String url = getUrl("datax/task/run/A3成果质检_表格数据检查", req); |
| | | |
| | |
| | | return RestHelper.postForRest(url, list); |
| | | } |
| | | |
| | | /** |
| | | * 3.点云检查:.laz + *激光点云*.xls/.xlsx |
| | | */ |
| | | public String checkLaz(FmeReqEntity fme, HttpServletRequest req) { |
| | | String url = getUrl("datax/task/run/A9成果质检_点云检查", req); |
| | | |
| | |
| | | return RestHelper.postForRest(url, list); |
| | | } |
| | | |
| | | /** |
| | | * 4.高程检查:.tif/.prj/.tfw/.tif.ovr + *地形图*.dwg |
| | | */ |
| | | public String checkDem(FmeReqEntity fme, HttpServletRequest req) { |
| | | String url = getUrl("datax/task/run/A6成果质检_高程检查", req); |
| | | |
| | |
| | | return RestHelper.postForRest(url, list); |
| | | } |
| | | |
| | | /** |
| | | * 5.属性检查:*dlg*.gdb + *地形图*.dwg |
| | | */ |
| | | public String checkAttrs(FmeReqEntity fme, HttpServletRequest req) { |
| | | String url = getUrl("datax/task/run/A5成果质检_属性检查", req); |
| | | |
| | |
| | | return RestHelper.postForRest(url, list); |
| | | } |
| | | |
| | | /** |
| | | * 6.拓扑检查:*地形图*.dwg |
| | | */ |
| | | public String checkTopology(FmeReqEntity fme, HttpServletRequest req) { |
| | | String url = getUrl("datax/task/run/A4成果质检_拓扑检查", req); |
| | | |
| | |
| | | return RestHelper.postForRest(url, list); |
| | | } |
| | | |
| | | /** |
| | | * 7.图面整饰检查:.dwg |
| | | */ |
| | | public String checkDecorate(FmeReqEntity fme, HttpServletRequest req) { |
| | | String url = getUrl("datax/task/run/A10成果质检_图面整饰检查", req); |
| | | |
| | |
| | | return RestHelper.postForRest(url, list); |
| | | } |
| | | |
| | | /** |
| | | * 8.原点检查:*剖面图*.dwg |
| | | */ |
| | | public String checkOrigin(FmeReqEntity fme, HttpServletRequest req) { |
| | | String url = getUrl("datax/task/run/A11成果质检_原点检查", req); |
| | | |
| | |
| | | return RestHelper.postForRest(url, list); |
| | | } |
| | | |
| | | /** |
| | | * 9.栅格检查:.tif/.prj/.tfw/.tif.ovr + .xls/.xlsx |
| | | */ |
| | | public String checkDom(FmeReqEntity fme, HttpServletRequest req) { |
| | | String url = getUrl("datax/task/run/A7成果质检_栅格检查", req); |
| | | |
| | |
| | | return RestHelper.postForRest(url, list); |
| | | } |
| | | |
| | | /** |
| | | * 10.数学基础检查:.shp, .gdb, *元数据*.xls/.xlsx |
| | | */ |
| | | public String checkMath(FmeReqEntity fme, HttpServletRequest req) { |
| | | String url = getUrl("datax/task/run/B1入库质检_数学基础检查", req); |
| | | |
| | |
| | | return RestHelper.postForRest(url, list); |
| | | } |
| | | |
| | | /** |
| | | * 11.元数据检查:*元数据*.xls/.xlsx |
| | | */ |
| | | public String checkMeta(FmeReqEntity fme, HttpServletRequest req) { |
| | | String url = getUrl("datax/task/run/B5入库质检_元数据检查", req); |
| | | |
| | |
| | | return RestHelper.postForRest(url, list); |
| | | } |
| | | |
| | | /** |
| | | * 12.总质检:.zip/.7z + .xls/.xlsx |
| | | */ |
| | | public String checkMain(FmeReqEntity fme, HttpServletRequest req) { |
| | | String url = getUrl("datax/task/run/B0入库质检__总", req); |
| | | |
| | |
| | | return RestHelper.postForRest(url, list); |
| | | } |
| | | |
| | | /** |
| | | * 13.逻辑一致性检查:.dwg/.xls/.xlsx |
| | | */ |
| | | public String checkLogical(FmeReqEntity fme, HttpServletRequest req) { |
| | | String url = getUrl("datax/task/run/B3入库质检_逻辑一致性检查", req); |
| | | |
| | |
| | | return RestHelper.postForRest(url, list); |
| | | } |
| | | |
| | | /** |
| | | * 14.单项成果完整性检查:.* |
| | | */ |
| | | public String checkSingleIntegrity(FmeReqEntity fme, HttpServletRequest req) { |
| | | String url = getUrl("datax/task/run/B6入库质检_单项成果完整性检查", req); |
| | | |
| | |
| | | return RestHelper.postForRest(url, list); |
| | | } |
| | | |
| | | /** |
| | | * a.表格入库:S_RKBG、dirid、parentid,多个以英文逗号隔开 |
| | | */ |
| | | public String excelLoader(MetaFileEntity meta, HttpServletRequest req) { |
| | | String url = getUrl("datax/task/run/表格入库", req); |
| | | |
| | |
| | | return RestHelper.postForRest(url, list); |
| | | } |
| | | |
| | | /** |
| | | * b.CRDS平台交付 |
| | | */ |
| | | public String crdsPackaging(String dirCode, String major, String isCut, HttpServletRequest req) { |
| | | // datax/task/run/CRDS平台交付_测试 |
| | | String url = getUrl("datax/task/run/CRDS平台交付_code测试", req); |
| | |
| | | return RestHelper.postForRest(url, list); |
| | | } |
| | | |
| | | /** |
| | | * c.服务注册 |
| | | */ |
| | | public RegisterEntity serverRegister(String name, String serverUri, String type, HttpServletRequest req) { |
| | | String url = getUrl("resource/res/item", req); |
| | | |
| | |
| | | return entity; |
| | | } |
| | | |
| | | /** |
| | | * d.服务申请 |
| | | */ |
| | | public void serverApply(String id, Integer pubid, HttpServletRequest req) { |
| | | String url = getUrl("resource/res/request", req) + "&resourceid=" + id; |
| | | |
| | |
| | | RestHelper.postForRest(url, entity); |
| | | } |
| | | |
| | | /** |
| | | * e.删除资源 |
| | | */ |
| | | public void deleteRes(String id, HttpServletRequest req) { |
| | | String url = getUrl("resource/res/hashid", req) + "&hashid=" + id; |
| | | |
| | | RestHelper.deleteForRest(url); |
| | | } |
| | | |
| | | /** |
| | | * 获取Url |
| | | */ |
| | | public String getUrl(String subUrl, HttpServletRequest req) { |
| | | String token = WebHelper.getToken(req); |
| | | |
| | | return fmeUrl + subUrl + "?token=" + token; |
| | | } |
| | | |
| | | /** |
| | | * 获取名称值对集合 |
| | | */ |
| | | public List<NameValueEntity> getKeyValues(String name) { |
| | | List<NameValueEntity> list = new ArrayList<>(); |
| | | list.add(new NameValueEntity("_name", String.format("%s_%s", name, StringHelper.YMDHMS2_FORMAT.format(new Date())))); |
| | |
| | | import java.io.FileInputStream; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 元数据 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class MetaService implements MetaMapper { |
| | | @Autowired |
| | | PathHelper pathHelper; |
| | |
| | | return metaMapper.updates(list); |
| | | } |
| | | |
| | | /** |
| | | * 删除元数据 |
| | | */ |
| | | public Integer deletes(List<Integer> list) { |
| | | String ids = StringHelper.join(list, ","); |
| | | |
| | |
| | | return deletes(sql, ids); |
| | | } |
| | | |
| | | /** |
| | | * 获取删除表记录SQL |
| | | */ |
| | | public String getDelTabsSql(List<MetaEntity> metas) { |
| | | List<String> list = getTabDeletes(metas, metas.get(0).getTab()); |
| | | addCascadDeletes(list); |
| | |
| | | return StringHelper.join(list, ";"); |
| | | } |
| | | |
| | | /** |
| | | * 获取删除表记录SQL |
| | | */ |
| | | private List<String> getTabDeletes(List<MetaEntity> metas, String tab) { |
| | | List<String> list = new ArrayList<>(); |
| | | |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 添加级联删除 |
| | | */ |
| | | private void addCascadDeletes(List<String> list) { |
| | | int i = 0, c = list.size(); |
| | | while (i < c) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加附件删除 |
| | | */ |
| | | private void addAttachDeletes(List<String> list) { |
| | | int i = 0, c = list.size(); |
| | | while (i < c) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查看文件 |
| | | */ |
| | | public void downloadForView(String guid, boolean inline, HttpServletResponse res) { |
| | | try { |
| | | if (StringHelper.isEmpty(guid)) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询元数据中溢出的单位ID |
| | | */ |
| | | public List<String> selectMetaOverflowDep(UserEntity ue, DownloadReqEntity dr) { |
| | | String ids = StringHelper.join(dr.getIds(), ","); |
| | | |
| | | return selectMetaOverflowDep(ids, ue.getDepcode()); |
| | | } |
| | | |
| | | /** |
| | | * 请求元数据下载 |
| | | * |
| | | * @param ue 用户实体 |
| | | * @param dr 请求下载实体 |
| | | * @return 下载文件GUID |
| | | * @throws Exception 异常 |
| | | */ |
| | | public String downloadMeteReq(UserEntity ue, DownloadReqEntity dr) throws Exception { |
| | | List<MetaEntity> list = selectMetaFiles(dr.getIds()); |
| | | if (null == list || list.isEmpty()) { |
| | |
| | | return rows > 0 ? de.getGuid() : null; |
| | | } |
| | | |
| | | /** |
| | | * 获取数据表 |
| | | */ |
| | | private Map<String, List<String>> getTabs(List<MetaEntity> list) { |
| | | Map<String, List<String>> tabs = new HashMap<>(2); |
| | | for (MetaEntity meta : list) { |
| | |
| | | return tabs; |
| | | } |
| | | |
| | | /** |
| | | * 移除重复的元数据文件 |
| | | */ |
| | | private void rmRepeatMetas(List<MetaEntity> list) { |
| | | List<String> guidList = new ArrayList<>(); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询数据 |
| | | */ |
| | | private void queryData(Map<String, List<String>> tabs, Map<String, List<?>> dataMap, Map<String, List<AttachEntity>> annexMap) { |
| | | for (String tab : tabs.keySet()) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加数据 |
| | | */ |
| | | public void addData(String entity, BasicMapper baseMapper, QueryWrapper wrapper, Map<String, List<?>> dataMap, Map<String, List<AttachEntity>> annexMap) { |
| | | List list = baseMapper.selectList(wrapper); |
| | | if (null == list || list.size() == 0) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建查询包装器 |
| | | */ |
| | | private <T> QueryWrapper<T> createQueryWrapper(BasicMapper baseMapper, List<String> ids) { |
| | | for (int i = 0, c = ids.size(); i < c; i++) { |
| | | ids.set(i, "'" + ids.get(i) + "'"); |
| | |
| | | return wrapper; |
| | | } |
| | | |
| | | /** |
| | | * 添加附件 |
| | | */ |
| | | public void addAnnex(ZipFile zip, ZipParameters params, Map<String, List<AttachEntity>> annexMap) { |
| | | List<String> files = new ArrayList<>(); |
| | | String uploadPath = pathHelper.getConfig().getUploadPath(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加元数据文件至Zip包 |
| | | */ |
| | | private void addMetaFiles(ZipFile zip, ZipParameters params, List<MetaEntity> list) { |
| | | List<String> names = new ArrayList<>(); |
| | | String uploadPath = pathHelper.getConfig().getUploadPath(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加目录文件 |
| | | */ |
| | | private void addFolderFile(String uploadPath, MetaEntity mf, ZipFile zip, ZipParameters params) throws Exception { |
| | | File file = new File(uploadPath + File.separator + mf.getPath()); |
| | | if (!file.exists() || !file.isDirectory()) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加多文件 |
| | | */ |
| | | private void addMultiFile(String uploadPath, MetaEntity mf, ZipFile zip, ZipParameters params, List<String> extList) throws Exception { |
| | | addSingleFile(uploadPath, mf, zip, params); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加单文件 |
| | | */ |
| | | private void addSingleFile(String uploadPath, MetaEntity mf, ZipFile zip, ZipParameters params) throws Exception { |
| | | File file = new File(uploadPath + File.separator + mf.getPath()); |
| | | if (!file.exists() || file.isDirectory()) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取下载实体类 |
| | | */ |
| | | private DownloadEntity getDownloadEntity(UserEntity ue, String file, String pwd) { |
| | | DownloadEntity de = new DownloadEntity(); |
| | | de.setName(FileHelper.getFileName(file)); |
| | |
| | | return de; |
| | | } |
| | | |
| | | /** |
| | | * 插入元数据-下载表 |
| | | */ |
| | | private void insertMetaDown(UserEntity ue, List<MetaEntity> metas, DownloadEntity de) { |
| | | List<MetaDownEntity> list = new ArrayList<>(); |
| | | for (MetaEntity me : metas) { |
| | |
| | | metaDownService.inserts(list); |
| | | } |
| | | |
| | | /** |
| | | * 获取空间过滤 |
| | | */ |
| | | public String getGeometryFilter(String wkt) throws Exception { |
| | | if (StringHelper.isEmpty(wkt)) { |
| | | return null; |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 数据发布 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class PublishService implements PublishMapper { |
| | | @Value("${sys.exportServer}") |
| | | private String exportServer; |
| | |
| | | return publishMapper.selectMetasByPage(depcode, dircode, verid, types, name, limit, offset); |
| | | } |
| | | |
| | | /** |
| | | * 发送发布请求 |
| | | */ |
| | | public long postForPub(PubEntity entity, String method, HttpServletRequest req) { |
| | | Map<String, Object> map = getMapData(entity); |
| | | |
| | |
| | | return msg.getCount(); |
| | | } |
| | | |
| | | /** |
| | | * 获取Map数据 |
| | | */ |
| | | private Map<String, Object> getMapData(PubEntity entity) { |
| | | Map<String, Object> map = new HashMap<>(3); |
| | | |
| | |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 发送发布请求 |
| | | */ |
| | | public long postForPub(PubEntity entity, String method) { |
| | | Map<String, Object> map = getMapData(entity); |
| | | |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 读取栅格服务 |
| | | * @author WWW |
| | | * @date 2023-08-25 |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class ReadRasterService { |
| | | private final static Log log = LogFactory.getLog(ReadRasterService.class); |
| | | |
| | | /** |
| | | * 读取栅格信息 |
| | | */ |
| | | public void readRasterInfo(MetaFileEntity mf, String file) { |
| | | Dataset ds = null; |
| | | try { |
| | |
| | | } |
| | | |
| | | SpatialReference sr = ds.GetSpatialRef(); |
| | | // 坐标系统 |
| | | mf.setCoorSys(sr.GetName()); |
| | | if (StaticData.MOON200.equals(mf.getCoorSys())) { |
| | | // EPSG编码 |
| | | mf.setEpsg("ESRI:" + StaticData.I104903); |
| | | } else { |
| | | // EPSG编码:PROJCS、GEOGCS、GEOGCS|UNIT 或 NULL |
| | | String code = sr.GetAuthorityCode(null); |
| | | mf.setEpsg(StringHelper.isEmpty(code) ? null : "EPSG:" + code); |
| | | } |
| | | |
| | | // 行列数 |
| | | mf.setGridsize(String.format("%d,%d", ds.getRasterXSize(), ds.getRasterYSize())); |
| | | // 波段数 |
| | | mf.setBands(String.valueOf(ds.getRasterCount())); |
| | | // 数据类型 |
| | | int dataType = ds.GetRasterBand(1).GetRasterDataType(); |
| | | mf.setBandType(getDataType(dataType)); |
| | | // 数据颜色表 |
| | | ColorTable colorTable = ds.GetRasterBand(1).GetRasterColorTable(); |
| | | mf.setCt(null == colorTable ? null : colorTable.toString()); |
| | | // 高程基准 |
| | | mf.sethDatum(null); |
| | | // 设置最值 |
| | | setMinAndMax(ds, mf); |
| | | |
| | | // 分辨率 |
| | | double[] tr = new double[6]; |
| | | ds.GetGeoTransform(tr); |
| | | mf.setResolution(String.format("%f,%f", tr[1], Math.abs(tr[5]))); |
| | |
| | | double xmax = maxPoint.GetX(0); |
| | | double ymax = maxPoint.GetY(0); |
| | | |
| | | // 四至范围 |
| | | String geom = String.format("ST_GeomFromText('POLYGON ((%f %f,%f %f,%f %f,%f %f,%f %f))')", xmin, ymax, xmax, ymax, xmax, ymin, xmin, ymin, xmin, ymax); |
| | | mf.setGeom(geom); |
| | | } catch (Exception ex) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取数据类型 |
| | | */ |
| | | private String getDataType(int dataType) { |
| | | if (dataType == gdalconst.GDT_Byte) { |
| | | return "GDT_Byte"; |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 获取Dataset的最小点 |
| | | */ |
| | | private Geometry getMinPoint(Dataset ds) { |
| | | double[] transform = new double[6]; |
| | | ds.GetGeoTransform(transform); |
| | |
| | | return transform(ds, point); |
| | | } |
| | | |
| | | /** |
| | | * 获取Dataset的最大点 |
| | | */ |
| | | private Geometry getMaxPoint(Dataset ds) { |
| | | /* |
| | | * transform[0] 左上角x坐标 |
| | | * transform[1] 东西方向分辨率 |
| | | * transform[2] 旋转角度, 0表示图像 "北方朝上" |
| | | * |
| | | * transform[3] 左上角y坐标 |
| | | * transform[4] 旋转角度, 0表示图像 "北方朝上" |
| | | * transform[5] 南北方向分辨率 |
| | | */ |
| | | double[] transform = new double[6]; |
| | | ds.GetGeoTransform(transform); |
| | | |
| | |
| | | return transform(ds, point); |
| | | } |
| | | |
| | | /** |
| | | * 坐标转换 |
| | | */ |
| | | private Geometry transform(Dataset ds, Geometry point) { |
| | | point.AssignSpatialReference(ds.GetSpatialRef()); |
| | | if (ds.GetSpatialRef().IsGeographic() > 0) { |
| | |
| | | return point; |
| | | } |
| | | |
| | | /** |
| | | * 设置最值 |
| | | * GDALRasterBand::GetHistogram 统计直方图 |
| | | */ |
| | | private void setMinAndMax(Dataset ds, MetaFileEntity mf) { |
| | | List<Double> minList = new ArrayList<>(); |
| | | List<Double> maxList = new ArrayList<>(); |
| | |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 栅格分析服务 |
| | | * @author WWW |
| | | * @date 2023-11-16 |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class SlopeAnalysisService { |
| | | @Value("${sys.path.slopFile}") |
| | | private String filePath; |
| | |
| | | |
| | | private final static Log log = LogFactory.getLog(SlopeAnalysisService.class); |
| | | |
| | | /** |
| | | * 获取Excel模板 |
| | | */ |
| | | private String getXlsTemplate() throws IOException { |
| | | if (null == xlsTemplate) { |
| | | xlsTemplate = FileHelper.getClassPathForWar() + File.separator + "config" + File.separator + "slope.xlsx"; |
| | |
| | | return xlsTemplate; |
| | | } |
| | | |
| | | /** |
| | | * 下载坡度分析Excel |
| | | */ |
| | | public void downloadSlopXls(Geometry polygon, HttpServletResponse res) throws Exception { |
| | | Dataset ds = null; |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 分析多边形 |
| | | */ |
| | | public List<PointEntity> analysisPolygon(Geometry geo, Dataset ds) { |
| | | double[] transform = ds.GetGeoTransform(); |
| | | int xSize = ds.getRasterXSize(), ySize = ds.getRasterYSize(); |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 创建Excel |
| | | */ |
| | | public String createXls(List<PointEntity> list, String template) { |
| | | String target = pathHelper.getTempPath() + File.separator + "slope_" + StringHelper.YMD2_FORMAT.format(new Date()) + ".xlsx"; |
| | | |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 数据上传服务类 |
| | | * |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class UploadService extends BaseUploadService implements UploadMapper { |
| | | @Autowired |
| | | UploadMapper uploadMapper; |
| | |
| | | return uploadMapper.selectFmeLog(parentid); |
| | | } |
| | | |
| | | /** |
| | | * 插入文件 |
| | | */ |
| | | public void insertFiles(UserEntity ue, List<MetaFileEntity> list, HttpServletRequest req) { |
| | | checkMetaFiles(ue, list); |
| | | readRasterInfo(list); |
| | |
| | | insertMetas(list); |
| | | } |
| | | |
| | | /** |
| | | * 检查元数据文件 |
| | | */ |
| | | private void checkMetaFiles(UserEntity ue, List<MetaFileEntity> list) { |
| | | Timestamp createTime = WebHelper.getCurrentTimestamp(); |
| | | String tempPath = pathHelper.getConfig().getTempPath(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 读取栅格信息 |
| | | */ |
| | | private void readRasterInfo(List<MetaFileEntity> list) { |
| | | for (MetaFileEntity mf : list) { |
| | | if (null != mf.getMsg()) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取目录编码 |
| | | */ |
| | | private String getDirCode(MetaFileEntity mf) { |
| | | if (StringHelper.isEmpty(mf.getDircode())) { |
| | | return null; |
| | |
| | | return StringHelper.getRightLike(mf.getDircode().substring(0, 2)); |
| | | } |
| | | |
| | | /** |
| | | * 获取Excel元数据文件 |
| | | */ |
| | | private List<MetaFileEntity> getExcelFiles(List<MetaFileEntity> list) { |
| | | List<MetaFileEntity> xlsList = new ArrayList<>(); |
| | | for (MetaFileEntity mf : list) { |
| | |
| | | return xlsList; |
| | | } |
| | | |
| | | /** |
| | | * 是/否为Excel |
| | | */ |
| | | private boolean isExcel(MetaFileEntity mf) { |
| | | return StaticData.XLS.equals(mf.getExtName()) || StaticData.XLSX.equals(mf.getExtName()); |
| | | } |
| | | |
| | | /** |
| | | * 获取Xls目录 |
| | | */ |
| | | private String getXlsPath(String filePath) { |
| | | String tempPath = pathHelper.getConfig().getTempPath() + File.separator; |
| | | String subPath = filePath.substring(tempPath.length()); |
| | |
| | | return subPath; |
| | | } |
| | | |
| | | /** |
| | | * 复制Xls文件 |
| | | */ |
| | | private String copyXlsFile(String xlsBasePath, int i, MetaFileEntity mf) { |
| | | try { |
| | | String xlsPath = xlsBasePath + File.separator + i; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 加载数据 |
| | | */ |
| | | private void loadData(List<MetaFileEntity> list) { |
| | | for (MetaFileEntity mf : list) { |
| | | if (null != mf.getMsg() || StringHelper.isEmpty(mf.getEntity())) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 加载空间数据 |
| | | */ |
| | | public void loadSpatialData(MetaFileEntity mf) { |
| | | BasicMapper basicMapper = ClassHelper.getBasicMapper(mf.getEntity()); |
| | | if (null == basicMapper) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 批量插入 |
| | | */ |
| | | private <T> int batchInserts(BasicMapper basicMapper, List<T> list) { |
| | | int rows = 0; |
| | | //int count = (int) Math.ceil(list.size() / StaticData.D100) |
| | |
| | | return rows; |
| | | } |
| | | |
| | | /** |
| | | * 设置创建信息 |
| | | */ |
| | | private <T> void setCreateInfo(List<T> list, MetaFileEntity mf) { |
| | | try { |
| | | if (!(list.get(0) instanceof BaseEntity)) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 复制文件 |
| | | */ |
| | | private void copyFiles(List<MetaFileEntity> list) { |
| | | List<String> gdbList = new ArrayList<>(); |
| | | for (MetaFileEntity mf : list) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 复制单个文件 |
| | | */ |
| | | private int copySingleFile(MetaFileEntity mf) { |
| | | File file = new File(mf.getPath()); |
| | | if (!file.exists()) { |
| | |
| | | return 1; |
| | | } |
| | | |
| | | /** |
| | | * 设置旧元数据信息 |
| | | */ |
| | | private void setOldMeta(MetaFileEntity mf, MetaEntity old) { |
| | | mf.setPath(old.getPath()); |
| | | mf.setTab(old.getTab()); |
| | |
| | | mf.setEntity(old.getEventid()); |
| | | } |
| | | |
| | | /** |
| | | * 复制多个文件 |
| | | */ |
| | | private void copyMultiFile(MetaFileEntity mf, List<String> extList) { |
| | | String path = mf.getPath(); |
| | | int status = copySingleFile(mf); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 复制文件夹文件 |
| | | */ |
| | | private void copyFolderFile(MetaFileEntity mf) { |
| | | File file = new File(mf.getPath()); |
| | | if (!file.exists()) { |
| | |
| | | mf.setPath(subPath); |
| | | } |
| | | |
| | | /** |
| | | * 根据GUID查找路径 |
| | | */ |
| | | private String findPathByGuid(List<MetaFileEntity> list, MetaFileEntity mf) { |
| | | for (MetaFileEntity meta : list) { |
| | | if (meta.getGuid().equals(mf.getGuid()) && !meta.getPath().equals(mf.getPath())) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 创建文件链接 |
| | | */ |
| | | private void createFileLink(String source, String target) { |
| | | String cmd = String.format("cmd /c mklink \"%s\" \"%s\"", target, source); |
| | | WebHelper.exec(cmd); |
| | | } |
| | | |
| | | /** |
| | | * 插入元数据 |
| | | */ |
| | | private void insertMetas(List<MetaFileEntity> list) { |
| | | int metaId = insertParentMeta(list); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建元数据 |
| | | */ |
| | | private MetaEntity createMeta(MetaFileEntity mf, int metaId) { |
| | | MetaEntity me = new MetaEntity(); |
| | | me.setMetaid(metaId); |
| | |
| | | return me; |
| | | } |
| | | |
| | | /** |
| | | * 插入父元数据 |
| | | */ |
| | | private int insertParentMeta(List<MetaFileEntity> list) { |
| | | for (MetaFileEntity mf : list) { |
| | | if (null != mf.getMsg() || !mf.getIsMeta()) { |
| | |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * Excel入库 |
| | | */ |
| | | private String excelLoader(List<MetaFileEntity> xlsList, HttpServletRequest req) { |
| | | try { |
| | | MetaFileEntity xlsMeta = getExcelMeta(xlsList); |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 获取Excel的元数据 |
| | | */ |
| | | private MetaFileEntity getExcelMeta(List<MetaFileEntity> xlsList) { |
| | | if (null == xlsList || xlsList.isEmpty()) { |
| | | return null; |
| | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 数据申请 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class ApplyService implements ApplyMapper { |
| | | @Autowired |
| | | ApplyMapper applyMapper; |
| | |
| | | return applyMapper.updateForReject(userid, applyid, flowId); |
| | | } |
| | | |
| | | /** |
| | | * 插入数据申请 |
| | | */ |
| | | public Integer insertApply(UserEntity ue, DownloadReqEntity dr) throws Exception { |
| | | ApplyEntity apply = getApplyEntity(ue, dr); |
| | | int rows = applyMapper.insert(apply); |
| | |
| | | return flowService.inserts(list); |
| | | } |
| | | |
| | | /** |
| | | * 获取数据申请实体类 |
| | | */ |
| | | private ApplyEntity getApplyEntity(UserEntity ue, DownloadReqEntity dr) throws Exception { |
| | | // String dbPwd = Md5Helper.reverse(Md5Helper.generate(dr.getPwd())) |
| | | String aesPwd = AesHelper.encrypt(dr.getPwd()); |
| | |
| | | return apply; |
| | | } |
| | | |
| | | /** |
| | | * 获取表名 |
| | | */ |
| | | private String getTabs(DownloadReqEntity dr) { |
| | | if (!StaticData.SYS_META.equals(dr.getEntities().get(0))) { |
| | | return StringHelper.join(dr.getTabs(), ","); |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 获取申请流程实体类集合 |
| | | */ |
| | | private List<FlowEntity> getFlowEntities(Integer applyId, UserEntity ue, DownloadReqEntity dr) { |
| | | List<FlowEntity> list = new ArrayList<>(); |
| | | for (String depcode : dr.getDepcodes()) { |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 打包DB数据 |
| | | */ |
| | | public void zipDbData(UserEntity ue, ApplyEntity entity) { |
| | | try { |
| | | List<String> entities = Arrays.asList(entity.getEntities().split(StaticData.COMMA)); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取ID集合 |
| | | */ |
| | | private List<Integer> getIds(String gids) { |
| | | if (StringHelper.isEmpty(gids)) { |
| | | return null; |
| | |
| | | import java.io.File; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 资料馆 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class DataLibService { |
| | | @Autowired |
| | | PathHelper pathHelper; |
| | |
| | | |
| | | private final static Log log = LogFactory.getLog(DataLibService.class); |
| | | |
| | | /** |
| | | * 查询DB中溢出的单位编码 |
| | | */ |
| | | public List<String> selectDbOverflowDep(UserEntity ue, DownloadReqEntity dr) { |
| | | if (!StringHelper.isEmpty(dr.getWkt())) { |
| | | return selectDbOverflowDep4Wkt(ue, dr); |
| | |
| | | return selectDbOverflowDep4Prop(ue, dr); |
| | | } |
| | | |
| | | /** |
| | | * 查询DB中溢出的单位编码-空间查询 |
| | | */ |
| | | public List<String> selectDbOverflowDep4Wkt(UserEntity ue, DownloadReqEntity dr) { |
| | | List<String> rs = new ArrayList<>(); |
| | | for (String entity : dr.getEntities()) { |
| | |
| | | return rs; |
| | | } |
| | | |
| | | /** |
| | | * 查询DB中溢出的单位编码-属性查询 |
| | | */ |
| | | public List<String> selectDbOverflowDep4Prop(UserEntity ue, DownloadReqEntity dr) { |
| | | List<String> rs = new ArrayList<>(); |
| | | BasicMapper<?> baseMapper = ClassHelper.getBasicMapper(dr.getEntities().get(0)); |
| | |
| | | return rs; |
| | | } |
| | | |
| | | /** |
| | | * 查询DB中溢出单位编码的查询包装器 |
| | | */ |
| | | private <T> QueryWrapper<T> getWrapper4DbOverflow(UserEntity ue, DownloadReqEntity dr) { |
| | | QueryWrapper<T> wrapper = new QueryWrapper<T>(); |
| | | wrapper.select("depid"); |
| | |
| | | return wrapper; |
| | | } |
| | | |
| | | /** |
| | | * 添加单位编码 |
| | | */ |
| | | private void addDepCodes(List<String> rs, List<String> ids) { |
| | | if (null == ids || ids.isEmpty()) { |
| | | return; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 请求DB数据下载 |
| | | */ |
| | | public String downloadDbReq(UserEntity ue, DownloadReqEntity dr) throws Exception { |
| | | Map<String, List<?>> dataMap = new HashMap<>(2); |
| | | Map<String, List<AttachEntity>> annexMap = new HashMap<>(2); |
| | |
| | | return rows > 0 ? de.getGuid() : null; |
| | | } |
| | | |
| | | /** |
| | | * 查询数据+附件 |
| | | */ |
| | | private void queryData(DownloadReqEntity dr, Map<String, List<?>> dataMap, Map<String, List<AttachEntity>> annexMap) { |
| | | for (String entity : dr.getEntities()) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建查询包装器 |
| | | */ |
| | | private <T> QueryWrapper<T> createQueryWrapper(BasicMapper baseMapper, DownloadReqEntity dr) { |
| | | QueryWrapper<T> wrapper = new QueryWrapper<T>(); |
| | | |
| | |
| | | return wrapper; |
| | | } |
| | | |
| | | /** |
| | | * 创建附件 * |
| | | */ |
| | | private void createAnnex(String annexPath, Map<String, List<AttachEntity>> annexMap) { |
| | | if (annexMap.size() == 0) { |
| | | return; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取下载实体类 |
| | | */ |
| | | private DownloadEntity getDownloadEntity(UserEntity ue, String file, String pwd) { |
| | | DownloadEntity de = new DownloadEntity(); |
| | | de.setName(FileHelper.getFileName(file)); |
| | |
| | | return de; |
| | | } |
| | | |
| | | /** |
| | | * 处理编码 |
| | | */ |
| | | public static String copeCodes(String codes, String field) { |
| | | if (StringHelper.isEmpty(codes) || StringHelper.isSqlInjection(codes)) { |
| | | return null; |
| | |
| | | return "(" + StringHelper.join(list, " or ") + ")"; |
| | | } |
| | | |
| | | /** |
| | | * 单位编码转集合 |
| | | */ |
| | | private static List<String> codesAsList(String codes) { |
| | | List<String> list = Arrays.asList(codes.split(",")); |
| | | Set set = new HashSet(list); |
| | |
| | | return newList; |
| | | } |
| | | |
| | | /** |
| | | * 处理目录编码 |
| | | */ |
| | | private static List<String> copeDirCodes(List<String> list) { |
| | | List<String> prjList = getDirCodesByLen(list, 0, 2); |
| | | List<String> appList = getDirCodesByLen(list, 3, 30); |
| | |
| | | return filterCodes(prjList, appList); |
| | | } |
| | | |
| | | /** |
| | | * 根据长度获取单位编码 |
| | | */ |
| | | private static List<String> getDirCodesByLen(List<String> list, int start, int end) { |
| | | List<String> rs = new ArrayList<>(); |
| | | for (String code : list) { |
| | |
| | | return rs; |
| | | } |
| | | |
| | | /** |
| | | * 过滤项目编码 |
| | | */ |
| | | private static List<String> filterCodes(List<String> prjList, List<String> appList) { |
| | | int i = 0; |
| | | while (i < appList.size()) { |
| | |
| | | return appList; |
| | | } |
| | | |
| | | /** |
| | | * 设置 右like |
| | | */ |
| | | private static void setRightLike(List<String> list, String field) { |
| | | if (list.isEmpty()) { |
| | | list.add("1 = 2"); |
| | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 在线制图 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class ExportService { |
| | | @Value("${sys.exportServer}") |
| | | private String exportServer; |
| | |
| | | @Autowired |
| | | DownloadService downloadService; |
| | | |
| | | /** |
| | | * POST请求出图服务 |
| | | * |
| | | * @param ue 用户类 |
| | | * @param entity 在线制图类 |
| | | * @return 成功 |
| | | * @throws Exception |
| | | */ |
| | | public String post(UserEntity ue, ExportEntity entity) throws Exception { |
| | | Map<String, Object> map = getMapData(entity); |
| | | String url = exportServer + "/Export/Start"; |
| | |
| | | return rows > 0 ? de.getGuid() : null; |
| | | } |
| | | |
| | | /** |
| | | * 获取Map数据 |
| | | */ |
| | | private Map<String, Object> getMapData(ExportEntity entity) { |
| | | Map<String, Object> map = new HashMap<String, Object>(3); |
| | | |
| | |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 获取下载实体类 |
| | | */ |
| | | private DownloadEntity getDownloadEntity(UserEntity ue, ExportEntity entity, String file) throws Exception { |
| | | DownloadEntity de = new DownloadEntity(); |
| | | de.setName(FileHelper.getFileName(file)); |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 申请流程 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class FlowService implements FlowMapper { |
| | | @Autowired |
| | | FlowMapper flowMapper; |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 查询服务类 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class InquiryService { |
| | | @Resource |
| | | PathHelper pathHelper; |
| | |
| | | |
| | | private final static Log log = LogFactory.getLog(InquiryService.class); |
| | | |
| | | /** |
| | | * 读取Shp第一条记录的WKT |
| | | */ |
| | | public ShpRecordEntity readShpFirstRecord(List<MetaFileEntity> list) { |
| | | String fileName = null; |
| | | for (MetaFileEntity mf : list) { |
| | |
| | | return sr; |
| | | } |
| | | |
| | | /** |
| | | * 打包瓦片 |
| | | */ |
| | | public String zipTiles(DownloadTileEntity dt, PublishEntity pub, UserEntity ue) { |
| | | if (!isTilePathExist(pub)) { |
| | | return null; |
| | |
| | | return rows > 0 ? de.getGuid() : null; |
| | | } |
| | | |
| | | /** |
| | | * 瓦片路径是否存在 |
| | | */ |
| | | private boolean isTilePathExist(PublishEntity pub) { |
| | | String tilePath = pathHelper.getConfig().getTilePath() + pub.getPath(); |
| | | |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 查找瓦片 |
| | | */ |
| | | private List<File> findTiles(DownloadTileEntity dt, PublishEntity pub) { |
| | | List<File> list = new ArrayList<>(); |
| | | |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 根据层次查找瓦片 |
| | | */ |
| | | private List<File> findTilesByZoom(DownloadTileEntity dt, PublishEntity pub, int zoom) { |
| | | List<File> list = new ArrayList<>(); |
| | | File f = new File(pub.getPath() + File.separator + zoom); |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 角度转数值 |
| | | */ |
| | | private int[] deg2num(int zoom, double x, double y) { |
| | | double yRad = Math.toRadians(y); |
| | | double n = Math.pow(2.0, zoom); |
| | |
| | | return new int[]{xTile, yTile}; |
| | | } |
| | | |
| | | /** |
| | | * 添加文件至压缩包 |
| | | */ |
| | | private void addFiles(ZipFile zip, ZipParameters params, List<File> list, String basePath) { |
| | | for (File f : list) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取下载实体类 |
| | | */ |
| | | private DownloadEntity getDownloadEntity(UserEntity ue, String file, String pwd) { |
| | | DownloadEntity de = new DownloadEntity(); |
| | | de.setName(FileHelper.getFileName(file)); |
| | |
| | | return de; |
| | | } |
| | | |
| | | /** |
| | | * 插入数据发布-下载表 |
| | | */ |
| | | private void insertPubDown(PublishEntity pub, DownloadEntity de, UserEntity ue) { |
| | | publishService.insertPubDown(pub.getId(), de.getId(), ue.getId()); |
| | | } |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 标绘 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class MarkService implements MarkMapper { |
| | | @Resource |
| | | MarkMapper markMapper; |
| | |
| | | return markMapper.updates(list); |
| | | } |
| | | |
| | | /** |
| | | * 下载ShapeFile文件 |
| | | * |
| | | * @param ue 用户实体 |
| | | * @param list 标绘JSON实体类集合 |
| | | * @return GUID |
| | | * @throws Exception 异常 |
| | | */ |
| | | public String downloadShp(UserEntity ue, List<MarkJsonEntity> list) throws Exception { |
| | | String path = pathHelper.getTempPath(); |
| | | createShapeFiles(ue, list, path); |
| | |
| | | return rows > 0 ? de.getGuid() : null; |
| | | } |
| | | |
| | | /** |
| | | * 创建shp文件 |
| | | */ |
| | | private String createShapeFiles(UserEntity ue, List<MarkJsonEntity> list, String path) { |
| | | List<MarkJsonEntity> points = getMarkByType(list, "POINT"); |
| | | if (points.size() > 0) { |
| | |
| | | return path; |
| | | } |
| | | |
| | | /** |
| | | * 获取shp目录 |
| | | */ |
| | | private String getShpDir(UserEntity ue, String parent) { |
| | | String path = parent + File.separator + StringHelper.YMDHMS2_FORMAT.format(new Date()); |
| | | |
| | |
| | | return path; |
| | | } |
| | | |
| | | /** |
| | | * 获取标绘类型 |
| | | */ |
| | | private List<MarkJsonEntity> getMarkByType(List<MarkJsonEntity> list, String type) { |
| | | List<MarkJsonEntity> rs = new ArrayList<>(); |
| | | for (MarkJsonEntity mark : list) { |
| | |
| | | return rs; |
| | | } |
| | | |
| | | /** |
| | | * 获取zip路径 |
| | | */ |
| | | private String getZipPath() { |
| | | String path = pathHelper.getDownloadFullPath() + File.separator + StringHelper.YMDHMS2_FORMAT.format(new Date()) + ".zip"; |
| | | |
| | |
| | | return path; |
| | | } |
| | | |
| | | /** |
| | | * 获取下载实体类 |
| | | */ |
| | | private DownloadEntity getDownloadEntity(UserEntity ue, String file) throws Exception { |
| | | DownloadEntity de = new DownloadEntity(); |
| | | de.setName(FileHelper.getFileName(file)); |
| | |
| | | return de; |
| | | } |
| | | |
| | | /** |
| | | * 获取下载文件路径 |
| | | */ |
| | | public String getDownloadFilePath(DownloadEntity de) { |
| | | return pathHelper.getConfig().getDownloadPath() + File.separator + de.getUrl(); |
| | | } |
| | | |
| | | /** |
| | | * 读取ShapeFile文件获取Mark实体类 |
| | | */ |
| | | public List<MarkJsonEntity> readShpForMarks(List<MetaFileEntity> list) { |
| | | String fileName = null; |
| | | for (MetaFileEntity mf : list) { |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 模型 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class ModelService implements ModelMapper { |
| | | @Autowired |
| | | ModelMapper modelMapper; |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 管道分析服务类 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class PipelineService implements PipelineMapper { |
| | | @Autowired |
| | | PathHelper pathHelper; |
| | |
| | | return pipelineMapper.selectPipeAnalysis(tab, gid); |
| | | } |
| | | |
| | | /** |
| | | * 创建Zip包 |
| | | * |
| | | * @param ue 用户实体 |
| | | * @param map 管道分析数据集合 |
| | | * @param pwd 密码 |
| | | * @return 下载文件GUID |
| | | */ |
| | | public String createZipFile(UserEntity ue, Map<String, List<PipelineEntity>> map, String pwd) throws Exception { |
| | | String tempName = StringHelper.YMDHMS2_FORMAT.format(new Date()); |
| | | String tempPath = pathHelper.getTempPath(tempName); |
| | |
| | | return rows > 0 ? downloadEntity.getGuid() : null; |
| | | } |
| | | |
| | | /** |
| | | * 创建GDB |
| | | */ |
| | | public static void createGdb(String filePath, Map<String, List<PipelineEntity>> map) throws Exception { |
| | | Driver driver = null; |
| | | DataSource dataSource = null; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建图层 |
| | | */ |
| | | private static Layer createLayer(DataSource dataSource, String tab, PipelineEntity pe) { |
| | | int geomType = pe.getWkt().contains("POINT") ? ogr.wkbMultiPoint : ogr.wkbMultiLineString; |
| | | |
| | |
| | | return dataSource.CreateLayer(tab, sr, geomType, null); |
| | | } |
| | | |
| | | /** |
| | | * 获取字段 |
| | | */ |
| | | private static void getFields(Class clazz, List<Field> list) { |
| | | try { |
| | | Field[] fields = clazz.getDeclaredFields(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置图层数据 |
| | | */ |
| | | private static void setLayerData(Layer layer, List<Field> fields, List<PipelineEntity> list) throws Exception { |
| | | for (PipelineEntity t : list) { |
| | | Feature f = new Feature(layer.GetLayerDefn()); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加Zip文件 |
| | | */ |
| | | private void addZipFiles(ZipFile zip, ZipParameters params, File[] files) { |
| | | if (null == files || files.length == 0) { |
| | | return; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取下载实体类 |
| | | */ |
| | | private DownloadEntity getDownloadEntity(UserEntity ue, String file, String pwd) throws Exception { |
| | | DownloadEntity de = new DownloadEntity(); |
| | | de.setName(FileHelper.getFileName(file)); |
| | |
| | | import java.lang.reflect.Field; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 参数设置 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class ArgsService implements ArgsMapper { |
| | | @Autowired |
| | | ArgsMapper argsMapper; |
| | |
| | | return argsMapper.updates(list); |
| | | } |
| | | |
| | | /** |
| | | * 初始化设置值 |
| | | */ |
| | | public void initSettingData() throws Exception { |
| | | List<ArgsEntity> list = selectAll(); |
| | | if (list == null || list.isEmpty()) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新设置值 |
| | | */ |
| | | public void updateSettingData(ArgsEntity entity) throws Exception { |
| | | Field field = SettingData.class.getField(entity.getMark()); |
| | | // field.setAccessible(true) |
| | |
| | | import java.lang.reflect.Field; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 附件 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class AttachService implements AttachMapper { |
| | | @Autowired |
| | | AttachMapper attachMapper; |
| | |
| | | return attachMapper.selectFmeLogs(tabs); |
| | | } |
| | | |
| | | /** |
| | | * 查询FME日志 |
| | | */ |
| | | public List<FmeLogEntity> selectFmeLogs() { |
| | | if (StringHelper.isEmpty(tabs)) { |
| | | tabs = UploadAttachService.getTabs().replace("'", ""); |
| | |
| | | return attachMapper.insertAttachByMeta(tab, tabGuid, metaName, dirid); |
| | | } |
| | | |
| | | /** |
| | | * 同步附件 |
| | | */ |
| | | public void syncAttaches(FmeLogEntity entity) { |
| | | String tab = entity.getPgNs() + "." + entity.getTcdm(); |
| | | String fieldName = UploadAttachService.ATTACH_TABS.get(tab); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取目录编码 |
| | | */ |
| | | private String getDirid(BaseEntity be) { |
| | | if (StringHelper.isEmpty(be.getDirid())) { |
| | | return null; |
| | |
| | | return StringHelper.getRightLike(dirid); |
| | | } |
| | | |
| | | /** |
| | | * 根据父ID查询记录 |
| | | */ |
| | | private List<?> selectRowsByParentid(String entity, String parentid, String field) { |
| | | BasicMapper baseMapper = ClassHelper.getBasicMapper(entity); |
| | | if (null == baseMapper) { |
| | |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * 黑名单 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class BlacklistService implements BlacklistMapper { |
| | | @Autowired |
| | | BlacklistMapper blacklistMapper; |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 清空缓存 |
| | | */ |
| | | public void clearCache() { |
| | | redisService.clearKeys(RedisCacheKey.blacklistKey("")); |
| | | } |
| | |
| | | import java.sql.Timestamp; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 下载日志 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class DownlogService implements DownlogMapper { |
| | | @Autowired |
| | | DownlogMapper downlogMapper; |
| | |
| | | return downlogMapper.updates(list); |
| | | } |
| | | |
| | | /** |
| | | * 更新下载信息 |
| | | */ |
| | | public void updateInfos(UserEntity ue, DownloadEntity de, HttpServletRequest req) { |
| | | de.setDcount(de.getDcount() + 1); |
| | | de.setDownloadUser(ue.getId()); |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 菜单-权限 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class MenuAuthService implements MenuAuthMapper { |
| | | @Autowired |
| | | MenuAuthMapper menuAuthMapper; |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 元数据-下载 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class MetaDownService implements MetaDownMapper { |
| | | @Autowired |
| | | MetaDownMapper metaDownMapper; |
| | |
| | | import java.util.TimerTask; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * 代理服务类 |
| | | * @author WWW |
| | | * @date 2023-07-11 |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class ProxyService { |
| | | @Resource |
| | | RedisService redisService; |
| | |
| | | |
| | | public static final String ILLEGAL_RESOURCE = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.UNAUTHORIZED, "没有资源访问权限")); |
| | | |
| | | /** |
| | | * URL代理 |
| | | */ |
| | | public void proxyUrl(String token, int resId, boolean isRest, HttpServletRequest req, HttpServletResponse res) throws Exception { |
| | | // 3.获取用户 |
| | | UserEntity ue = getUser(req, res, token); |
| | | if (null == ue) { |
| | | return; |
| | | } |
| | | // 9.获取资源实体,status:0-禁用,1-启用原始地址,2-启用代理地址 |
| | | |
| | | ResEntity entity = getResEntity(ue, resId); |
| | | if (null == entity || StaticData.I1 > entity.getStatus() || StringHelper.isNull(entity.getProxy()) || StringHelper.isNull(entity.getUrl())) { |
| | | WebHelper.writeStr2Page(res, ILLEGAL_RESOURCE); |
| | |
| | | forward(req, res, entity, url); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户 |
| | | */ |
| | | private UserEntity getUser(HttpServletRequest req, HttpServletResponse res, String token) { |
| | | String key = RedisCacheKey.permsProxy(token); |
| | | Object obj = redisService.get(key); |
| | |
| | | return ue; |
| | | } |
| | | |
| | | /** |
| | | * 检查 |
| | | */ |
| | | private boolean check(HttpServletRequest req, HttpServletResponse res, UserEntity ue, String token) { |
| | | // 4.获取IP |
| | | String ip = WebHelper.getIpAddress(req); |
| | | if (StringHelper.isEmpty(ip)) { |
| | | return WebHelper.writeStr2Page(res, AuthInterceptor.IP_NULL); |
| | | } |
| | | // 5.检查黑名单 |
| | | if (!checkBlackList(ip, req)) { |
| | | return WebHelper.writeStr2Page(res, AuthInterceptor.BLACK_LIST); |
| | | } |
| | | // 6.admin跳过权限检测 |
| | | if (StaticData.ADMIN.equals(ue.getUid())) { |
| | | return true; |
| | | } |
| | | // 7.检查白名单和IP一致性 |
| | | if (!checkWhiteList(ip, req)) { |
| | | if (!checkIpSource(ip, token)) { |
| | | return WebHelper.writeStr2Page(res, AuthInterceptor.ILLEGAL_TOKEN); |
| | | } |
| | | } |
| | | // 8.检查用户ID是否禁用 |
| | | if (sysService.tokenService.isUidDisable(ue)) { |
| | | return WebHelper.writeStr2Page(res, AuthInterceptor.USER_LOCK); |
| | | } |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 检查黑名单 |
| | | */ |
| | | private boolean checkBlackList(String ip, HttpServletRequest request) { |
| | | List<String> blackList = sysService.blacklistService.selectIpList(1); |
| | | if (blackList == null || blackList.isEmpty()) { |
| | |
| | | return !blackList.contains(ip); |
| | | } |
| | | |
| | | /** |
| | | * 检查白名单 |
| | | */ |
| | | private boolean checkWhiteList(String ip, HttpServletRequest request) { |
| | | List<String> whiteList = sysService.blacklistService.selectIpList(2); |
| | | if (whiteList == null || whiteList.isEmpty()) { |
| | |
| | | return whiteList.contains(ip); |
| | | } |
| | | |
| | | /** |
| | | * 检查IP一致性:固定令牌不检查 |
| | | */ |
| | | private boolean checkIpSource(String ip, String token) { |
| | | TokenEntity te = sysService.tokenService.getEntityByToken(token); |
| | | |
| | | return StaticData.I1 == te.getType() || te.getIp().equals(ip); |
| | | } |
| | | |
| | | /** |
| | | * 检查资源权限 |
| | | */ |
| | | private ResEntity getResEntity(UserEntity ue, int resId) { |
| | | List<ResEntity> rs = StaticData.ADMIN.equals(ue.getUid()) ? permsService.selectAllRes() : permsService.selectRes(ue.getUid()); |
| | | if (null == rs || rs.isEmpty()) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 插入日志 |
| | | */ |
| | | private void insertLog(HttpServletRequest req, UserEntity ue, int resId) { |
| | | String ip = WebHelper.getIpAddress(req); |
| | | |
| | |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取请求类别 |
| | | */ |
| | | private int getRequestType(String method) { |
| | | // 请求类:1-GET,2-POST,3-PUT,4-DELETE,5-TRACE,6-HEAD,7-OPTIONS,8-CONNECT'; |
| | | switch (method) { |
| | | case "GET": |
| | | return 1; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取Url |
| | | */ |
| | | private String getUrl(HttpServletRequest req, UserEntity ue, ResEntity entity, String token, boolean isRest) { |
| | | String proxyUrl = entity.getProxy().replace("{token}", token); |
| | | int end = req.getRequestURL().indexOf(proxyUrl) + proxyUrl.length(); |
| | |
| | | return url; |
| | | } |
| | | |
| | | /** |
| | | * 获取GeoServer地址 |
| | | */ |
| | | private String getGeoServerUrl(HttpServletRequest req, UserEntity ue, ResEntity entity, String url) { |
| | | if (null == req.getQueryString()) { |
| | | return url; |
| | |
| | | return url + (url.contains("?") ? "&" : "?") + str; |
| | | } |
| | | |
| | | /** |
| | | * 过滤GeoServer图层 |
| | | */ |
| | | private String filterGeoLayers(UserEntity ue, String layers) { |
| | | List<String> tabs = StaticData.ADMIN.equals(ue.getUid()) ? permsService.selectAllTabs() : permsService.selectTabs(ue.getUid()); |
| | | if (null == tabs || tabs.isEmpty() || StringHelper.isEmpty(layers)) { |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 转发请求 |
| | | */ |
| | | private void forward(HttpServletRequest request, HttpServletResponse response, ResEntity entity, String url) throws Exception { |
| | | HttpHelper httpHelper = new HttpHelper(); |
| | | httpHelper.service(request, response, entity, url); |
| | |
| | | import java.io.File; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 报告模板 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class ReportService implements ReportMapper { |
| | | @Autowired |
| | | ReportMapper reportMapper; |
| | |
| | | return reportMapper.countSizesByPrj(); |
| | | } |
| | | |
| | | /** |
| | | * 创建报告 |
| | | */ |
| | | public void createReport(UserEntity ue, ReportEntity re, HttpServletResponse res) throws Exception { |
| | | AttachEntity ae = attachService.selectByGuid(re.getGuid()); |
| | | if (null == ae) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 生成报告 |
| | | */ |
| | | private void generateReport(String source, String target, ReportEntity re) { |
| | | if (StaticData.S1.equals(re.getType())) { |
| | | switch (re.getCode()) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建 用户流量统计 Word |
| | | */ |
| | | public void createCountOperatesWord(String source, String target) { |
| | | List<CountEntity> list = countOperates(); |
| | | if (null == list || list.isEmpty()) { |
| | |
| | | WordHelper.generateWord(source, target, null, addList); |
| | | } |
| | | |
| | | /** |
| | | * 创建 服务调用量统计 Word |
| | | */ |
| | | public void createCountServicesWord(String source, String target) { |
| | | List<CountEntity> list = countServices(); |
| | | if (null == list || list.isEmpty()) { |
| | |
| | | WordHelper.generateWord(source, target, null, addList); |
| | | } |
| | | |
| | | /** |
| | | * 创建 数据量统计 Word |
| | | */ |
| | | public void createCountSizesWord(String source, String target) { |
| | | List<CountEntity> list = countSizes(); |
| | | if (null == list || list.isEmpty()) { |
| | |
| | | WordHelper.generateWord(source, target, null, addList); |
| | | } |
| | | |
| | | /** |
| | | * 创建 用户流量统计 Excel |
| | | */ |
| | | public void createCountOperatesExcel(String source, String target) { |
| | | List<CountEntity> list = countOperates(); |
| | | if (null == list || list.isEmpty()) { |
| | |
| | | ExcelHelper.writeToTemplate(source, target, map); |
| | | } |
| | | |
| | | /** |
| | | * 创建 服务调用量统计 Excel |
| | | */ |
| | | public void createCountServicesExcel(String source, String target) { |
| | | List<CountEntity> list = countServices(); |
| | | if (null == list || list.isEmpty()) { |
| | |
| | | ExcelHelper.writeToTemplate(source, target, map); |
| | | } |
| | | |
| | | /** |
| | | * 创建 数据量统计 Excel |
| | | */ |
| | | public void createCountSizesExcel(String source, String target) { |
| | | List<CountEntity> list = countSizes(); |
| | | if (null == list || list.isEmpty()) { |
| | |
| | | ExcelHelper.writeToTemplate(source, target, map); |
| | | } |
| | | |
| | | /** |
| | | * 获取下载实体类 |
| | | */ |
| | | private DownloadEntity getDownloadEntity(UserEntity ue, String file) { |
| | | DownloadEntity de = new DownloadEntity(); |
| | | de.setName(FileHelper.getFileName(file)); |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 资源日志 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class ResLogService implements ResLogMapper { |
| | | @Autowired |
| | | ResLogMapper resLogMapper; |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 资源 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class ResService implements ResMapper { |
| | | @Autowired |
| | | ResMapper resMapper; |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 角色-图层 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class RoleLayerService implements RoleLayerMapper { |
| | | @Autowired |
| | | RoleLayerMapper roleLayerMapper; |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 角色-菜单 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class RoleMenuAuthService implements RoleMenuAuthMapper { |
| | | @Autowired |
| | | RoleMenuAuthMapper roleMenuAuthMapper; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 角色-资源 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class RoleResService implements RoleResMapper { |
| | | @Resource |
| | | RoleResMapper roleResMapper; |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 角色-用户 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class RoleUserService implements RoleUserMapper { |
| | | @Autowired |
| | | RoleUserMapper roleUserMapper; |