管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-03-23 1043217a0ee3ef22fec9697a8620d20e070ea350
1
已添加1个文件
已修改1个文件
521 ■■■■ 文件已修改
src/main/java/com/lf/server/config/InitConfig.java 245 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/all/TestService.java 276 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/config/InitConfig.java
@@ -1,27 +1,8 @@
package com.lf.server.config;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lf.server.entity.all.MenusAuthEntity;
import com.lf.server.entity.all.PermsAuthEntity;
import com.lf.server.entity.all.ResAuthEntity;
import com.lf.server.entity.bd.DlgagnpEntity;
import com.lf.server.entity.data.MetaEntity;
import com.lf.server.entity.data.MetaFileEntity;
import com.lf.server.entity.md.*;
import com.lf.server.helper.*;
import com.lf.server.mapper.bd.DlgagnpMapper;
import com.lf.server.service.all.BaseQueryService;
import com.lf.server.service.all.PermsService;
import com.lf.server.service.all.UploadAttachService;
import com.lf.server.service.data.MetaService;
import com.lf.server.service.data.UploadService;
import com.lf.server.service.show.LocateService;
import com.lf.server.service.sys.ArgsService;
import com.lf.server.service.sys.BlacklistService;
import com.lf.server.service.sys.ReportService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -30,17 +11,11 @@
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * åˆå§‹åŒ–完成配置类
 * @author WWW
 */
@Component
@SuppressWarnings("AlibabaRemoveCommentedCode")
public class InitConfig implements ApplicationRunner {
    private final static Log log = LogFactory.getLog(InitConfig.class);
@@ -51,239 +26,21 @@
    ArgsService argsService;
    @Autowired
    DlgagnpMapper dlgagnpMapper;
    @Autowired
    PermsService permsService;
    @Autowired
    BlacklistService blacklistService;
    @Autowired
    BaseQueryService baseQueryService;
    @Autowired
    LocateService locateService;
    @Autowired
    Environment env;
    @Autowired
    ReportService reportService;
    @Autowired
    UploadService uploadService;
    @Autowired
    MetaService metaService;
    @Override
    public void run(ApplicationArguments args) {
        // noinspection AlibabaRemoveCommentedCode
        try {
            //GdalHelper.readTif("E:\\data\\7.Insar\\insartest.tif")
            //GdalHelper.readShp("E:\\data\\13.cppe\\shps\\addr.shp");
            //GdalHelper.readGdb("E:\\Test\\addr.gdb");
            //GdalHelper.readShpFirstRecord("D:\\LF\\data\\shp\\extent.shp");
            //com.lf.server.helper.RsaHelper.generate();
            //FloatServerController.test();
            //testReadExcel();
            //boolean f1 = ZipHelper.unzip("D:\\LF\\data\\resources.zip", "D:\\LF\\data\\unzip");
            //boolean f2 = ZipHelper.zip("D:\\LF\\data\\res.zip", "D:\\LF\\data\\unzip\\resources");
            //boolean f3 = Zip4jHelper.zip("D:\\LF\\data\\zip\\resources.zip", "D:\\LF\\data\\zip\\resources", "12345");
            //boolean f4 = Zip4jHelper.unzip("D:\\LF\\data\\zip\\resources.zip", "D:\\LF\\data\\zip\\res", "12345");
            // åˆå§‹åŒ–
            GdalHelper.init(env.getProperty("sys.gdal_path"));
            UploadAttachService.init(env.getProperty("sys.attachTabs"));
            pathHelper.init();
            argsService.initSettingData();
            //testReadShp();
            //testMeta();
            log.info("***************** ç³»ç»Ÿå¯åŠ¨å®Œæ¯• *****************" + "\n");
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        }
    }
    private void testMeta() {
        List<MetaEntity> list = metaService.selectByIdsForTab("1501,1500,1491,1492");
        String sql = metaService.getDelTabsSql(list);
    }
    private void testReadShp() {
        MetaFileEntity mf = new MetaFileEntity();
        //mf.setPath("D:\\model_data\\m_sitepoint.shp");
        mf.setPath("D:\\shpto\\m_sitepoint.shp");
        mf.setEntity("msitepoint");
        mf.setGuid("msitepoint");
        mf.setTab("bs.m_sitepoint");
        mf.setExtName(".shp");
        uploadService.loadSpatialData(mf);
    }
    private void testBatchUpdate() {
        DlgagnpEntity d1 = new DlgagnpEntity();
        d1.setGid(56);
        d1.setGb("10");
        d1.setName("a01");
        DlgagnpEntity d2 = new DlgagnpEntity();
        d2.setGid(57);
        d2.setGb("20");
        d2.setName("a02");
        List<DlgagnpEntity> list = new ArrayList<>();
        list.add(d1);
        list.add(d2);
        int rows = dlgagnpMapper.updateBatch(list);
    }
    private void testMybatisPlus() {
        String s1 = locateService.selectWktById(1);
        String tabName = BaseQueryService.getTabName(dlgagnpMapper);
        List<String> list0 = dlgagnpMapper.selectFieldFuzzy(tabName, "name", "%县%");
        DlgagnpEntity dlg = dlgagnpMapper.selectById(1);
        String wkt = dlgagnpMapper.selectWktById(tabName, 2);
        Map<String, Object> map = new HashMap<String, Object>(3);
        map.put("gid", 2);
        List<DlgagnpEntity> list1 = dlgagnpMapper.selectByMap(map);
        QueryWrapper<DlgagnpEntity> w1 = new QueryWrapper<>();
        w1.eq("name", "治多县");
        List<DlgagnpEntity> list2 = dlgagnpMapper.selectList(w1);
        UpdateWrapper<DlgagnpEntity> w2 = new UpdateWrapper<DlgagnpEntity>();
        // è®¾ç½®æ›´æ–°å†…容
        w2.set("name", "newName").set("gb", "10013")
                // è®¾ç½®æ›´æ–°æ¡ä»¶
                .eq("gid", 0);
        // dlgagnpMapper.update(null, w2)
        List<Integer> ids = new ArrayList<Integer>();
        ids.add(1);
        ids.add(2);
        // dlgagnpMapper.deleteBatchIds(ids)
        List<DlgagnpEntity> list3 = dlgagnpMapper.selectBatchIds(ids);
        // dlgagnpMapper.updateById(dlg)
        // List<DlgAgnp> all = dlgagnpMapper.selectList(null)
        // é¡µæ•° / æ¯é¡µè®°å½•æ•°
        Page<DlgagnpEntity> page = new Page<>(1, 10);
        // å‡åºæŽ’序
        page.addOrder(OrderItem.asc("gid"));
        // åˆ†é¡µï¼šWrapper查询条件
        Page<DlgagnpEntity> userPage = dlgagnpMapper.selectPage(page, null);
        // æ€»é¡µæ•° / æ€»è®°å½•数:325 / 3247
        String str = userPage.getPages() + " / " + userPage.getTotal();
        List<DlgagnpEntity> list4 = userPage.getRecords();
        QueryWrapper<DlgagnpEntity> w3 = new QueryWrapper<>();
        w3.like("name", "多").ge("gid", 100);
        List<DlgagnpEntity> list5 = dlgagnpMapper.selectList(w3);
    }
    private void testAes() {
        try {
            String content = "POLYGON ((115.94927385452 32.3754479115071 0,121.989371092554 32.2766788010181 0,121.850621222894 29.6874200067864 0,115.9727267226 29.7835368627922 0,115.94927385452 32.3754479115071 0))";
            System.out.println("加密前:" + content);
            String encrypt = AesHelper.encrypt(content);
            System.out.println("加密后:" + encrypt);
            String decrypt = AesHelper.decrypt(encrypt);
            System.out.println("解密后:" + decrypt);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        }
    }
    private void testPerms() {
        List<ResAuthEntity> raeList = permsService.selectRes("admin");
        List<ResAuthEntity> raeList2 = permsService.selectRes("admin");
        List<MenusAuthEntity> maeList = permsService.selectMenus("admin");
        List<MenusAuthEntity> maeList2 = permsService.selectMenus("admin");
        List<String> pList = permsService.selectPerms("admin");
        List<String> pList2 = permsService.selectPerms("admin");
        List<PermsAuthEntity> pauList = permsService.selectPermsEntity("admin");
        List<PermsAuthEntity> pauList2 = permsService.selectPermsEntity("admin");
        permsService.clearResCache();
        permsService.clearPermsCache();
        raeList = permsService.selectRes("admin");
        maeList = permsService.selectMenus("admin");
        pList = permsService.selectPerms("admin");
        pauList = permsService.selectPermsEntity("admin");
        permsService.clearAllCache();
    }
    private void testBlacklist() {
        List<String> list1 = blacklistService.selectIpList(1);
        List<String> list2 = blacklistService.selectIpList(1);
        List<String> list3 = blacklistService.selectIpList(2);
        List<String> list4 = blacklistService.selectIpList(2);
        blacklistService.clearCache();
        List<String> list5 = blacklistService.selectIpList(1);
    }
    private void testReadExcel() {
        List<?> listMdZxcg = ExcelHelper.readExcel(MdzxcgEntity.class, "D:\\LF\\data\\xls\\测绘\\1-项目成果-西三中\\1-1中线成果表\\海原县中线成果表.xlsx");
        int r1 = listMdZxcg.size();
        //List<MdGdcgEntity> listGdcg = ExcelHelper.readExcel(MdGdcgEntity.class, "D:\\LF\\data\\xls\\测绘\\2-地下管线探测成果\\2-2 ç®¡çº¿æˆæžœè¡¨.xlsx");
        //int r2 = listGdcg.size();
        String entityName = "Gxcg";
        String xls = "D:\\LF\\data\\xls\\测绘\\2-地下管线探测成果\\2-2 ç®¡çº¿æˆæžœè¡¨.xlsx";
        String className = "com.lf.server.entity.bs." + entityName;
        Object obj = ClassHelper.createInstance(className);
        List<?> list = ExcelHelper.readExcel(obj.getClass(), xls);
        int r3 = list.size();
    }
    private void testAccess() {
        List<Map<String, Object>> list = AccessHelper.readMdb("D:\\LF\\data\\test.mdb", "", "");
        int count = null == list || list.isEmpty() ? 0 : list.size();
    }
    private void testMd5() {
        try {
            String file = "E:\\data\\mpt\\A4mpt20131125.mpt";
            long stime = System.currentTimeMillis();
            // 2a0befb05146cd30213ee4b95038aca0
            String md51 = FileHelper.getFileMd5(file);
            long etime = System.currentTimeMillis();
            String s1 = String.format("执行时长:%d æ¯«ç§’.", (etime - stime));
            stime = System.currentTimeMillis();
            // 2a0befb05146cd30213ee4b95038aca0
            String md52 = FileHelper.getMd5ByJdk(file);
            etime = System.currentTimeMillis();
            String s2 = String.format("执行时长:%d æ¯«ç§’.", (etime - stime));
            stime = System.currentTimeMillis();
            // 9f1b7f050f41598710ffc08252484397
            String md53 = FileHelper.getFastMd5(file);
            etime = System.currentTimeMillis();
            String s3 = String.format("执行时长:%d æ¯«ç§’.", (etime - stime));
            etime = System.currentTimeMillis();
        } catch (Exception ex) {
            //
        }
    }
}
src/main/java/com/lf/server/service/all/TestService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,276 @@
package com.lf.server.service.all;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lf.server.entity.all.MenusAuthEntity;
import com.lf.server.entity.all.PermsAuthEntity;
import com.lf.server.entity.all.ResAuthEntity;
import com.lf.server.entity.bd.DlgagnpEntity;
import com.lf.server.entity.data.MetaEntity;
import com.lf.server.entity.data.MetaFileEntity;
import com.lf.server.entity.md.MdzxcgEntity;
import com.lf.server.helper.*;
import com.lf.server.mapper.bd.DlgagnpMapper;
import com.lf.server.service.data.FmeService;
import com.lf.server.service.data.MetaService;
import com.lf.server.service.data.UploadService;
import com.lf.server.service.show.LocateService;
import com.lf.server.service.sys.ArgsService;
import com.lf.server.service.sys.BlacklistService;
import com.lf.server.service.sys.ReportService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * æµ‹è¯•服务类
 * @author WWW
 */
@Service
@SuppressWarnings("AlibabaRemoveCommentedCode")
public class TestService {
    @Autowired
    PathHelper pathHelper;
    @Autowired
    ArgsService argsService;
    @Autowired
    DlgagnpMapper dlgagnpMapper;
    @Autowired
    PermsService permsService;
    @Autowired
    BlacklistService blacklistService;
    @Autowired
    BaseQueryService baseQueryService;
    @Autowired
    LocateService locateService;
    @Autowired
    Environment env;
    @Autowired
    ReportService reportService;
    @Autowired
    UploadService uploadService;
    @Autowired
    MetaService metaService;
    @Autowired
    FmeService fmeService;
    private final static Log log = LogFactory.getLog(TestService.class);
    public void testRegiste() {
        //
    }
    public void testGdal() {
        GdalHelper.readTif("E:\\data\\7.Insar\\insartest.tif");
        GdalHelper.readShp("E:\\data\\13.cppe\\shps\\addr.shp");
        GdalHelper.readGdb("E:\\Test\\addr.gdb");
        //GdalHelper.readShpFirstRecord("D:\\LF\\data\\shp\\extent.shp");
        com.lf.server.helper.RsaHelper.generate();
        //FloatServerController.test();
        testReadExcel();
        boolean f1 = ZipHelper.unzip("D:\\LF\\data\\resources.zip", "D:\\LF\\data\\unzip");
        boolean f2 = ZipHelper.zip("D:\\LF\\data\\res.zip", "D:\\LF\\data\\unzip\\resources");
        boolean f3 = Zip4jHelper.zip("D:\\LF\\data\\zip\\resources.zip", "D:\\LF\\data\\zip\\resources", "12345");
        boolean f4 = Zip4jHelper.unzip("D:\\LF\\data\\zip\\resources.zip", "D:\\LF\\data\\zip\\res", "12345");
    }
    public void testMeta() {
        List<MetaEntity> list = metaService.selectByIdsForTab("1501,1500,1491,1492");
        String sql = metaService.getDelTabsSql(list);
    }
    public void testReadShp() {
        MetaFileEntity mf = new MetaFileEntity();
        //mf.setPath("D:\\model_data\\m_sitepoint.shp");
        mf.setPath("D:\\shpto\\m_sitepoint.shp");
        mf.setEntity("msitepoint");
        mf.setGuid("msitepoint");
        mf.setTab("bs.m_sitepoint");
        mf.setExtName(".shp");
        uploadService.loadSpatialData(mf);
    }
    public void testBatchUpdate() {
        DlgagnpEntity d1 = new DlgagnpEntity();
        d1.setGid(56);
        d1.setGb("10");
        d1.setName("a01");
        DlgagnpEntity d2 = new DlgagnpEntity();
        d2.setGid(57);
        d2.setGb("20");
        d2.setName("a02");
        List<DlgagnpEntity> list = new ArrayList<>();
        list.add(d1);
        list.add(d2);
        int rows = dlgagnpMapper.updateBatch(list);
    }
    public void testMybatisPlus() {
        String s1 = locateService.selectWktById(1);
        String tabName = BaseQueryService.getTabName(dlgagnpMapper);
        List<String> list0 = dlgagnpMapper.selectFieldFuzzy(tabName, "name", "%县%");
        DlgagnpEntity dlg = dlgagnpMapper.selectById(1);
        String wkt = dlgagnpMapper.selectWktById(tabName, 2);
        Map<String, Object> map = new HashMap<String, Object>(3);
        map.put("gid", 2);
        List<DlgagnpEntity> list1 = dlgagnpMapper.selectByMap(map);
        QueryWrapper<DlgagnpEntity> w1 = new QueryWrapper<>();
        w1.eq("name", "治多县");
        List<DlgagnpEntity> list2 = dlgagnpMapper.selectList(w1);
        UpdateWrapper<DlgagnpEntity> w2 = new UpdateWrapper<DlgagnpEntity>();
        // è®¾ç½®æ›´æ–°å†…容
        w2.set("name", "newName").set("gb", "10013")
                // è®¾ç½®æ›´æ–°æ¡ä»¶
                .eq("gid", 0);
        // dlgagnpMapper.update(null, w2)
        List<Integer> ids = new ArrayList<Integer>();
        ids.add(1);
        ids.add(2);
        // dlgagnpMapper.deleteBatchIds(ids)
        List<DlgagnpEntity> list3 = dlgagnpMapper.selectBatchIds(ids);
        // dlgagnpMapper.updateById(dlg)
        // List<DlgAgnp> all = dlgagnpMapper.selectList(null)
        // é¡µæ•° / æ¯é¡µè®°å½•æ•°
        Page<DlgagnpEntity> page = new Page<>(1, 10);
        // å‡åºæŽ’序
        page.addOrder(OrderItem.asc("gid"));
        // åˆ†é¡µï¼šWrapper查询条件
        Page<DlgagnpEntity> userPage = dlgagnpMapper.selectPage(page, null);
        // æ€»é¡µæ•° / æ€»è®°å½•数:325 / 3247
        String str = userPage.getPages() + " / " + userPage.getTotal();
        List<DlgagnpEntity> list4 = userPage.getRecords();
        QueryWrapper<DlgagnpEntity> w3 = new QueryWrapper<>();
        w3.like("name", "多").ge("gid", 100);
        List<DlgagnpEntity> list5 = dlgagnpMapper.selectList(w3);
    }
    public void testAes() {
        try {
            String content = "POLYGON ((115.94927385452 32.3754479115071 0,121.989371092554 32.2766788010181 0,121.850621222894 29.6874200067864 0,115.9727267226 29.7835368627922 0,115.94927385452 32.3754479115071 0))";
            System.out.println("加密前:" + content);
            String encrypt = AesHelper.encrypt(content);
            System.out.println("加密后:" + encrypt);
            String decrypt = AesHelper.decrypt(encrypt);
            System.out.println("解密后:" + decrypt);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        }
    }
    public void testPerms() {
        List<ResAuthEntity> raeList = permsService.selectRes("admin");
        List<ResAuthEntity> raeList2 = permsService.selectRes("admin");
        List<MenusAuthEntity> maeList = permsService.selectMenus("admin");
        List<MenusAuthEntity> maeList2 = permsService.selectMenus("admin");
        List<String> pList = permsService.selectPerms("admin");
        List<String> pList2 = permsService.selectPerms("admin");
        List<PermsAuthEntity> pauList = permsService.selectPermsEntity("admin");
        List<PermsAuthEntity> pauList2 = permsService.selectPermsEntity("admin");
        permsService.clearResCache();
        permsService.clearPermsCache();
        raeList = permsService.selectRes("admin");
        maeList = permsService.selectMenus("admin");
        pList = permsService.selectPerms("admin");
        pauList = permsService.selectPermsEntity("admin");
        permsService.clearAllCache();
    }
    public void testBlacklist() {
        List<String> list1 = blacklistService.selectIpList(1);
        List<String> list2 = blacklistService.selectIpList(1);
        List<String> list3 = blacklistService.selectIpList(2);
        List<String> list4 = blacklistService.selectIpList(2);
        blacklistService.clearCache();
        List<String> list5 = blacklistService.selectIpList(1);
    }
    public void testReadExcel() {
        List<?> listMdZxcg = ExcelHelper.readExcel(MdzxcgEntity.class, "D:\\LF\\data\\xls\\测绘\\1-项目成果-西三中\\1-1中线成果表\\海原县中线成果表.xlsx");
        int r1 = listMdZxcg.size();
        //List<MdGdcgEntity> listGdcg = ExcelHelper.readExcel(MdGdcgEntity.class, "D:\\LF\\data\\xls\\测绘\\2-地下管线探测成果\\2-2 ç®¡çº¿æˆæžœè¡¨.xlsx");
        //int r2 = listGdcg.size();
        String entityName = "Gxcg";
        String xls = "D:\\LF\\data\\xls\\测绘\\2-地下管线探测成果\\2-2 ç®¡çº¿æˆæžœè¡¨.xlsx";
        String className = "com.lf.server.entity.bs." + entityName;
        Object obj = ClassHelper.createInstance(className);
        List<?> list = ExcelHelper.readExcel(obj.getClass(), xls);
        int r3 = list.size();
    }
    public void testAccess() {
        List<Map<String, Object>> list = AccessHelper.readMdb("D:\\LF\\data\\test.mdb", "", "");
        int count = null == list || list.isEmpty() ? 0 : list.size();
    }
    public void testMd5() {
        try {
            String file = "E:\\data\\mpt\\A4mpt20131125.mpt";
            long stime = System.currentTimeMillis();
            // 2a0befb05146cd30213ee4b95038aca0
            String md51 = FileHelper.getFileMd5(file);
            long etime = System.currentTimeMillis();
            String s1 = String.format("执行时长:%d æ¯«ç§’.", (etime - stime));
            stime = System.currentTimeMillis();
            // 2a0befb05146cd30213ee4b95038aca0
            String md52 = FileHelper.getMd5ByJdk(file);
            etime = System.currentTimeMillis();
            String s2 = String.format("执行时长:%d æ¯«ç§’.", (etime - stime));
            stime = System.currentTimeMillis();
            // 9f1b7f050f41598710ffc08252484397
            String md53 = FileHelper.getFastMd5(file);
            etime = System.currentTimeMillis();
            String s3 = String.format("执行时长:%d æ¯«ç§’.", (etime - stime));
            etime = System.currentTimeMillis();
        } catch (Exception ex) {
            //
        }
    }
}