Commit f6b93b1a authored by YangZhaoJun1's avatar YangZhaoJun1

Merge branch 'master' of http://103.249.252.109:90/lcy/education

parents 8ccdff94 05798fc2
...@@ -77,7 +77,7 @@ public class BCodeLxcServiceImpl implements BCodeLxcService { ...@@ -77,7 +77,7 @@ public class BCodeLxcServiceImpl implements BCodeLxcService {
/* config path*/ /* config path*/
String destPath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator + String destPath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator +
global.getLxcDockerfilePath() + File.separator + lxc.getUserId() ; global.getLxcDockerfilePath() + File.separator + lxc.getUserId() + File.separator;
result = freemarkerUtil.generatorFileFromModel(this.getModelProject(lxc.getCode()),destPath result = freemarkerUtil.generatorFileFromModel(this.getModelProject(lxc.getCode()),destPath
,param); ,param);
if(!result.isSuccess()) { if(!result.isSuccess()) {
......
...@@ -2,7 +2,6 @@ package org.rcisoft.business.bcode.service.impl; ...@@ -2,7 +2,6 @@ package org.rcisoft.business.bcode.service.impl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.rcisoft.business.bchapter.dao.BChapterRepository; import org.rcisoft.business.bchapter.dao.BChapterRepository;
import org.rcisoft.business.bchapter.entity.BChapter; import org.rcisoft.business.bchapter.entity.BChapter;
import org.rcisoft.business.bcode.model.BCodeFile; import org.rcisoft.business.bcode.model.BCodeFile;
...@@ -28,11 +27,8 @@ import org.springframework.stereotype.Service; ...@@ -28,11 +27,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/** /**
* Created by lcy on 18/1/3. * Created by lcy on 18/1/3.
...@@ -145,7 +141,7 @@ public class BCodeServiceImpl implements BCodeService { ...@@ -145,7 +141,7 @@ public class BCodeServiceImpl implements BCodeService {
*/ */
private List<BCodeFile> readProjectFile(String slId, String chapterId, String userInfo, String StudentCode) { private List<BCodeFile> readProjectFile(String slId, String chapterId, String userInfo, String StudentCode) {
BCodeLxc lxc = new BCodeLxc(); BCodeLxc lxc = new BCodeLxc();
Map param = new HashMap<>();
List<BCodeFile> codeFile = new ArrayList<>(); List<BCodeFile> codeFile = new ArrayList<>();
/*工程存储路径*/ /*工程存储路径*/
String path = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator String path = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator
...@@ -174,28 +170,20 @@ public class BCodeServiceImpl implements BCodeService { ...@@ -174,28 +170,20 @@ public class BCodeServiceImpl implements BCodeService {
/*容器是否已启动*/ /*容器是否已启动*/
byte[] results = rcRedisServiceImpl.getBytes(global.getLxcPrefix() + lxc.getUserId()); byte[] results = rcRedisServiceImpl.getBytes(global.getLxcPrefix() + lxc.getUserId());
if(null != results) { if(null != results) {
Map param = new HashMap<>();
lxc = SerializationUtils.deserializer(results, BCodeLxc.class); lxc = SerializationUtils.deserializer(results, BCodeLxc.class);
/*已开启*/ /*已开启*/
if(null != lxc && codeFile.size() > 0){ if(null != lxc && codeFile.size() > 0){
/*容器参数*/ /*容器参数*/
param.put("port", lxc.getContainerPort()); param.put("port", lxc.getContainerPort());
param.put("endTime",lxc.getShutdownDate().getTime()); param.put("endTime",lxc.getShutdownDate().getTime());
codeFile.get(0).setLxcParam(param);
} }
/*开启容器*/ /*开启容器*/
else{ else
CommandResult result = bCodeLxcServiceImpl.startBCodeLxc(lxc); this.startLxc(param,lxc);
/*启动失败*/
if(null == result || !result.isSuccess()){
log.error("启动失败" + result.getMessage());
throw new ServiceException(400,result.getMessage());
}
param.put("port", lxc.getContainerPort());
param.put("endTime",lxc.getShutdownDate().getTime());
}
codeFile.get(0).setLxcParam(param);
} }
else
this.startLxc(param,lxc);
codeFile.get(0).setLxcParam(param);
}catch (Exception e){ }catch (Exception e){
log.debug(path + " is not exist"); log.debug(path + " is not exist");
...@@ -205,6 +193,22 @@ public class BCodeServiceImpl implements BCodeService { ...@@ -205,6 +193,22 @@ public class BCodeServiceImpl implements BCodeService {
return codeFile; return codeFile;
} }
/**
* 启动
* @param param
* @param lxc
*/
private void startLxc(Map param,BCodeLxc lxc){
CommandResult result = bCodeLxcServiceImpl.startBCodeLxc(lxc);
/*启动失败*/
if(null == result || !result.isSuccess()){
log.error("启动失败" + result.getMessage());
throw new ServiceException(400,result.getMessage());
}
param.put("port", lxc.getContainerPort());
param.put("endTime",lxc.getShutdownDate().getTime());
}
/** /**
* 递归方法读取文件及子目录 * 递归方法读取文件及子目录
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.isoft.edu.api.business.bterm.dao.BTermRepository">
<resultMap id="BaseResultMap" type="com.isoft.edu.api.business.bterm.entity.BTerm">
<id column="business_id" jdbcType="VARCHAR" property="businessId"/>
<result column="start_date" jdbcType="DATE" property="startDate"/>
<result column="end_date" jdbcType="DATE" property="endDate"/>
<result column="is_start" jdbcType="VARCHAR" property="isStart"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="create_date" jdbcType="DATE" property="createDate"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="update_date" jdbcType="DATE" property="updateDate"/>
<result column="del_flag" jdbcType="VARCHAR" property="delFlag"/>
<result column="flag" jdbcType="VARCHAR" property="flag"/>
<result column="remarks" jdbcType="VARCHAR" property="remarks"/>
<result column="code" jdbcType="VARCHAR" property="code"/>
<result column="name" javaType="VARCHAR" property="name"/>
</resultMap>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment