forked from kidgrow-microservices-platform

luliqiang
2021-02-26 a7ce98e167ae05c2ee00e39733b35521353218cd
增加模板读取的错误处理和生成SQL文件时的错误处理
2 files modified
16 ■■■■ changed files
kidgrow-business/kidgrow-opration-center/kidgrow-opration-center-biz/src/main/java/com/kidgrow/oprationcenter/service/impl/PartnerDockingInfoServiceImpl.java 10 ●●●●● patch | view | raw | blame | history
kidgrow-business/kidgrow-opration-center/kidgrow-opration-center-server/src/main/java/com/kidgrow/oprationcenter/controller/PartnerDockingInfoController.java 6 ●●●● patch | view | raw | blame | history
kidgrow-business/kidgrow-opration-center/kidgrow-opration-center-biz/src/main/java/com/kidgrow/oprationcenter/service/impl/PartnerDockingInfoServiceImpl.java
@@ -31,6 +31,7 @@
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
@@ -129,8 +130,9 @@
        String updateTime = "";
        try {
            // 1、读取基础表结构SQL
            Resource resource = resourceLoader.getResource("classpath:template//imageServer_template.sql");
            Resource resource = resourceLoader.getResource("classpath:template"+ File.separator+"imageServer_template.sql");
            fileImput = resource.getInputStream();  //new FileInputStream("./template/imageServer_template.sql");
            if (fileImput != null) {
            dbSql = FileUtils.readFile(fileImput);
            // 2、读取医院信息表Hospital_Info,插入SQL文中
@@ -382,12 +384,18 @@
            // 8、所有SQL文合并入基本的SQL中
            dbSql += hospitalSQL + departmentSQL + doctorSQL + partnerSQL + serverSQL + serviceSQL;
            }
            else {
                log.error("ImageServerSQL-Template读取错误!");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (fileImput != null) {
                fileImput.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
kidgrow-business/kidgrow-opration-center/kidgrow-opration-center-server/src/main/java/com/kidgrow/oprationcenter/controller/PartnerDockingInfoController.java
@@ -155,6 +155,10 @@
    public void downLoadDataBase(@RequestBody PartnerDockingInfo partnerDockingInfo, HttpServletResponse response) {
        String dbSql = partnerDockingInfoService.createSQL(partnerDockingInfo);
        if ((dbSql  == null) ||(dbSql.isEmpty())) {
            log.error("创建私有云数据库脚本出错!");
        } else {
        OutputStream out = null;
        InputStream fileInputStream = null;
        try {
@@ -166,7 +170,6 @@
            response.setContentType("application/x-msdownload");
            response.addHeader("Content-Length", "" + arr.length);
            response.addHeader("Content-Disposition", "attachment; filename=\"" + partnerDockingInfo.getHospitalName()+partnerDockingInfo.getDepartmentName() + ".sql\"");
            out = response.getOutputStream();
@@ -192,3 +195,4 @@
        }
    }
}
}