use of com.hfut.exception.CustomException in project Workload by amoxu.
the class RemoteTeachServiceImpl method insertLoad.
@Override
public boolean insertLoad(RemoteTeachWorkload workload) throws Exception {
try {
int people = workload.getPeople();
// 46个人为一个班,每增加一个班增加0.1系数
workload.setClassCoefficient((float) (Math.round(people / 46F) * 0.1 + 0.9));
// 计算工作量 课时
workload.setWorkload(workload.getPeriod() * workload.getClassCoefficient());
// 计算酬金
workload.setMoney(PropertyUtil.getAllowance() * workload.getWorkload());
} catch (NullPointerException | DataIntegrityViolationException nop) {
throw new CustomException("请输入班级人数,学时,教学班");
}
if (workloadMapper.insertSelective(workload) == 0) {
return false;
}
return true;
}
use of com.hfut.exception.CustomException in project Workload by amoxu.
the class ToolKit method getFileFromBytes.
/**
* 根据字节数组获取File
*
* @param b 字节数组
* @param outputFile 输出的路径(保存路径)
* @return
*/
public static File getFileFromBytes(byte[] b, String outputFile) throws CustomException {
BufferedOutputStream stream = null;
File file;
try {
file = new File(outputFile);
FileOutputStream fstream = new FileOutputStream(file);
stream = new BufferedOutputStream(fstream);
stream.write(b);
} catch (Exception e) {
throw new CustomException("文件保存出错" + e);
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e1) {
throw new CustomException("文件流关闭出错");
}
}
}
return file;
}
Aggregations