9fd81101 康伟

kangwei:门户:吨水电耗、吨水药费,公式修改

         试题:批量上传代码
1 个父辈 c6392105
......@@ -383,24 +383,16 @@ public class ReportItemvService {
startTime = dateVO.getLastMonthStartTime();
endTime = dateVO.getLastMonthEndTime();
String dfValueSql = "select sum(cost) cost from report_electric_cost t where t.month >='"+DateUtils.formatDate(startTime,"yyyy-MM")+"' and t.month<='"+DateUtils.formatDate(endTime,"yyyy-MM")+"' ";
dfValueSql += " and t.depart_id in ("+JSUtils.quoteEach(departId,",")+")";
String dfValue = getJdbcTemplate().queryForObject(dfValueSql,String.class);
String dfValue = getDSDFsql(departId, startTime, endTime);
String dfTBValue = getDSDFsql( departId, DateUtils.getHbDate(startTime), DateUtils.getHbDate(endTime));
String dfHBValue = getDSDFsql(departId, DateUtils.getHbDate(startTime), DateUtils.getHbDate(endTime));
String dfTBValueSql = "select sum(cost) cost from report_electric_cost t where t.month >='"+DateUtils.formatDate(DateUtils.getTbDate(startTime),"yyyy-MM")+"' and t.month<='"+DateUtils.formatDate(DateUtils.getTbDate(endTime),"yyyy-MM")+"' ";
dfTBValueSql += " and t.depart_id in ("+JSUtils.quoteEach(departId,",")+")";
String dfTBValue = getJdbcTemplate().queryForObject(dfTBValueSql,String.class);
String dfHBValueSql = "select sum(cost) cost from report_electric_cost t where t.month >='"+DateUtils.formatDate(DateUtils.getHbDate(startTime),"yyyy-MM")+"' and t.month<='"+DateUtils.formatDate(DateUtils.getHbDate(endTime),"yyyy-MM")+"' ";
dfHBValueSql += " and t.depart_id in ("+JSUtils.quoteEach(departId,",")+")";
String dfHBValue = getJdbcTemplate().queryForObject(dfHBValueSql,String.class);
//出水量:+同比+环比
ReportItemVO csl_reportVO = ReportViewUtil.getSumValueByTBHB(ReportConstant.view2119,ReportConstant.field_CSL, departId, startTime, endTime);
//当月数据/环比、同比
FRportlCommandCenterVO nowMonthVO = new FRportlCommandCenterVO("月总电耗", "万kwh",JSUtils.divide(dlhjData.getValue(),10000), JSUtils.divide(dlhjData.getValueTb(),10000), JSUtils.divide(dlhjData.getValueHb(),10000));
//日均数据:/环比/同比
FRportlCommandCenterVO lastMonthVO = new FRportlCommandCenterVO("吨水电费","元/t",JSUtils.divide(dfValue,csl_reportVO.getValue()) ,JSUtils.divide(dfTBValue,csl_reportVO.getValueTb()) ,JSUtils.divide(dfHBValue,csl_reportVO.getValueHb()));
FRportlCommandCenterVO lastMonthVO = new FRportlCommandCenterVO("吨水电费","元/t",dfValue ,dfTBValue,dfHBValue);
//吨水消耗
FRportlCommandCenterVO lastYearVo = new FRportlCommandCenterVO("吨水电耗","kwh/t",dsdh_value ,dsdh_value_Tb,dsdh_value_Hb );
fRportlCommandCenterVOList.add( nowMonthVO) ;
......@@ -409,6 +401,19 @@ public class ReportItemvService {
return fRportlCommandCenterVOList;
}
//吨水电耗
private String getDSDFsql(String departId,String startTime,String endTime){
String dfValueSql = null;
String buildView2119 = ReportViewUtil.buildView(ReportConstant.view2119,ReportConstant.field_CSL, departId, startTime, endTime);
dfValueSql = " select round(avg(t.cost / bbb.CSL),2) 'cost' from report_electric_cost t left join (";
dfValueSql +=" select aaa.depart_id , sum(aaa.CSL) 'CSL' from " +buildView2119+" aaa group by aaa.depart_id )bbb on t.depart_id = bbb.depart_id";
dfValueSql += " where t.month='"+DateUtils.formatDate(startTime,"yyyy-MM")+"' and t.cost > 0";
if(StringUtils.isNotEmpty(departId)){
dfValueSql += " and t.depart_id in ("+JSUtils.quoteEach(departId,",")+")";
}
String dfValue = getJdbcTemplate().queryForObject(dfValueSql,String.class);
return dfValue;
}
/***
......@@ -442,9 +447,9 @@ public class ReportItemvService {
String dataViewName3a24_valueHB = ReportViewUtil.buildView(ReportConstant.view4411,"yyh", departIds, monthHB,monthHB);
String dataViewName3a24_valueTB = ReportViewUtil.buildView(ReportConstant.view4411,"yyh", departIds, monthTB,monthTB);
String sql = "select ";
sql += "(select ROUND(ifnull(avg(aaa.yyh),0) ,2) 'value' from " + dataViewName3a24_value+ "aaa) 'value',";
sql += "(select ROUND(ifnull(avg(aaa.yyh),0) ,2) 'value' from " + dataViewName3a24_valueHB+ "aaa) 'valueHb',";
sql += "(select ROUND(ifnull(avg(aaa.yyh),0) ,2) 'value' from " + dataViewName3a24_valueTB+ "aaa) 'valueTb' ";
sql += "(select ROUND(ifnull(avg(aaa.yyh),0) ,2) 'value' from " + dataViewName3a24_value+ "aaa where aaa.yyh > 0 ) 'value',";
sql += "(select ROUND(ifnull(avg(aaa.yyh),0) ,2) 'value' from " + dataViewName3a24_valueHB+ "aaa where aaa.yyh > 0 ) 'valueHb',";
sql += "(select ROUND(ifnull(avg(aaa.yyh),0) ,2) 'value' from " + dataViewName3a24_valueTB+ "aaa where aaa.yyh > 0 ) 'valueTb' ";
sql += " from dual";
JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
ReportItemVO dsyfReportVO = null;
......
package com.skua.modules.edu.controller;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
......@@ -56,19 +57,6 @@ public class QuestionController {
@Autowired
private IQuestionService questionService;
/**
* <pre>
* 分页列表查询
* </pre>
* @param question
* @param pageNo
* @param pageSize
* @param req
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@AutoLog(value = "在线考试-试题-分页列表查询")
@ApiOperation(value="在线考试-试题-分页列表查询", notes="在线考试-试题-分页列表查询")
@GetMapping(value = "/list")
......@@ -105,15 +93,6 @@ public class QuestionController {
return result;
}
/**
* <pre>
* 添加
* </pre>
* @param question
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@AutoLog(value = "在线考试-试题-添加")
@ApiOperation(value="在线考试-试题-添加", notes="在线考试-试题-添加")
@PostMapping(value = "/add")
......@@ -130,15 +109,7 @@ public class QuestionController {
}
return result;
}
/**
* <pre>
* 编辑
* </pre>
* @param question
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@AutoLog(value = "在线考试-试题-编辑")
@ApiOperation(value="在线考试-试题-编辑", notes="在线考试-试题-编辑")
@PutMapping(value = "/edit")
......@@ -155,18 +126,9 @@ public class QuestionController {
result.success("修改成功!");
}
}
return result;
}
/**
* <pre>
* 通过id删除
* </pre>
* @param id
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@AutoLog(value = "在线考试-试题-通过id删除")
@ApiOperation(value="在线考试-试题-通过id删除", notes="在线考试-试题-通过id删除")
@DeleteMapping(value = "/delete")
......@@ -186,15 +148,6 @@ public class QuestionController {
return Result.ok("删除成功!");
}
/**
* <pre>
* 批量删除
* </pre>
* @param ids
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@AutoLog(value = "在线考试-试题-批量删除")
@ApiOperation(value="在线考试-试题-批量删除", notes="在线考试-试题-批量删除")
@DeleteMapping(value = "/deleteBatch")
......@@ -297,39 +250,18 @@ public class QuestionController {
return result;
}
/**
* <pre>
* 导出excel
* </pre>
* @param request
* @param response
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@RequestMapping(value = "/exportXls")
@RequestMapping(value = "/exportXlsTemplate")
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
// Step.1 组装查询条件
QueryWrapper<Question> queryWrapper = null;
try {
String paramsStr = request.getParameter("paramsStr");
if (ConvertUtils.isNotEmpty(paramsStr)) {
String deString = URLDecoder.decode(paramsStr, "UTF-8");
Question question = JSON.parseObject(deString, Question.class);
queryWrapper = QueryGenerator.initQueryWrapper(question, request.getParameterMap());
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
//Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
List<Question> pageList = questionService.list(queryWrapper);
List<QuestionExcel> pageList = new ArrayList<>();
pageList.add( new QuestionExcel("单选", "车辆在较窄的山路上行驶时,如果靠山体的一方不让行,应怎样做?", "鸣喇叭催其让行", "保持正常车速行驶", "提前减速或停车避让", "向左占道,谨慎驶过", "A", ""));
pageList.add( new QuestionExcel("多选", "交通信号灯由( )组成。", "鸣喇叭催其让行", "红灯", "绿灯", "黄灯", "蓝", "ABC"));
//导出文件名称
mv.addObject(NormalExcelConstants.FILE_NAME, "在线考试-试题列表");
mv.addObject(NormalExcelConstants.CLASS, Question.class);
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("在线考试-试题列表数据", "导出人:Jeecg", "导出信息"));
mv.addObject(NormalExcelConstants.FILE_NAME, "选择题_批量导入模板");
mv.addObject(NormalExcelConstants.CLASS, QuestionExcel.class);
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("选择题_批量导入模板", "导出人", ""));
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
}
......@@ -356,7 +288,6 @@ public class QuestionController {
params.setNeedSave(true);
try {
String dbId = request.getParameter("dbId");
List<QuestionExcel> listQuestions = ExcelImportUtil.importExcel(file.getInputStream(), QuestionExcel.class, params);
questionService.batchImportExcel(listQuestions,dbId);
return Result.ok("文件导入成功!数据行数:" + listQuestions.size());
......
......@@ -42,7 +42,26 @@ public class QuestionOption implements Serializable {
@ApiModelProperty(value = "选项标题")
private String optionTitle;
/**正确答案*/
@Excel(name = "正确答案", width = 15)
@ApiModelProperty(value = "正确答案")
@Excel(name = "是否正确答案", width = 15)
@ApiModelProperty(value = "是否正确答案")
private String correct;
public QuestionOption(){
}
public QuestionOption(String alias, String optionTitle) {
this.alias = alias;
this.optionTitle = optionTitle;
}
public QuestionOption(String alias, String optionTitle, String correct) {
this.alias = alias;
this.optionTitle = optionTitle;
this.correct = correct;
}
public QuestionOption(String questionId,String alias, String optionTitle, String correct) {
this.questionId = questionId;
this.alias = alias;
this.optionTitle = optionTitle;
this.correct = correct;
}
}
......
package com.skua.modules.edu.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.skua.modules.edu.entity.QuestionOption;
/**
* 在线考试-试题
*/
public interface IQuestionOptionService extends IService<QuestionOption> {
}
......@@ -27,7 +27,7 @@ public interface IQuestionService extends IService<Question> {
* @param question
* @return
*/
public int saveQuestion(Question question)throws Exception;
public int saveQuestion(Question question);
/***
* 修改试题 以及试题选项
......
package com.skua.modules.edu.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.skua.modules.edu.entity.QuestionOption;
import com.skua.modules.edu.mapper.QuestionOptionMapper;
import com.skua.modules.edu.service.IQuestionOptionService;
import org.springframework.stereotype.Service;
/**
* 在线考试-试题选项
*/
@Service
public class QuestionOptionServiceImpl extends ServiceImpl<QuestionOptionMapper, QuestionOption> implements IQuestionOptionService {
}
......@@ -5,16 +5,20 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.gson.Gson;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.service.ISequenceService;
import com.skua.modules.edu.entity.Question;
import com.skua.modules.edu.entity.QuestionDB;
import com.skua.modules.edu.entity.QuestionOption;
import com.skua.modules.edu.mapper.QuestionMapper;
import com.skua.modules.edu.mapper.QuestionOptionMapper;
import com.skua.modules.edu.service.IQuestionOptionService;
import com.skua.modules.edu.service.IQuestionService;
import com.skua.modules.edu.vo.QuestionExcel;
import com.skua.modules.erp.entity.ApproveRecord;
import com.skua.modules.erp.mapper.ApproveRecordMapper;
import com.skua.tool.util.UniqIdUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
......@@ -31,9 +35,15 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
@Resource
private QuestionOptionMapper optionMapper;
@Autowired
private IQuestionOptionService questionOptionService;
@Resource
private ApproveRecordMapper recordMapper;
@Autowired
private ISequenceService sequenceService;
public IPage<Question> queryPageList(Page<Question> page, Question questionDB) {
return this.baseMapper.queryPageList(page,questionDB);
}
......@@ -48,16 +58,17 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
* @return
*/
@Transactional
public int saveQuestion(Question question)throws Exception{
public int saveQuestion(Question question){
int count = this.baseMapper.insert( question );
// 步骤2:批量插入试题选项集合
if(question.getOptionList() != null ){
for(QuestionOption option : question.getOptionList() ){
option.setQuestionId( question.getId() ) ;
optionMapper.insert( option );
// optionMapper.insert( option );
}
questionOptionService.saveBatch(question.getOptionList());
// 创建Gson实例
Gson gson = new Gson();
// 将List转换为Json字符串
......@@ -126,15 +137,53 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
* @param listQuestions
* @param dbId
*/
@Transactional
public void batchImportExcel(List<QuestionExcel> listQuestions, String dbId){
Question question = null;
List<QuestionOption> optionList = null;
// 创建Gson实例
Gson gson = new Gson();
if(listQuestions != null && !listQuestions.isEmpty()){
for(QuestionExcel questionExcel : listQuestions){
String questionId = UniqIdUtils.getInstance().getUniqID();
System.out.println("试题编号 = "+questionId);
question = new Question();
question.setQuestionDbId(dbId);
question.setId(questionId);
question.setQuestionAnswer(questionExcel.getAnswer());
question.setQuestionType(questionExcel.getQuestionType());//试题类型:1 单选、2多选、3判断
question.setQuestionTitle(questionExcel.getQuestionTitle());
question.setAnalyzes(questionExcel.getAnalyzes());//试题解析
optionList = new ArrayList<>();
if(StringUtils.isNotEmpty(questionExcel.getOptionA()))optionList.add( new QuestionOption(questionId,"A",questionExcel.getOptionA(),checkAnswer(questionExcel.getAnswer(),"A")) ) ;
if(StringUtils.isNotEmpty(questionExcel.getOptionB()))optionList.add( new QuestionOption(questionId,"B",questionExcel.getOptionB(),checkAnswer(questionExcel.getAnswer(),"B")) ) ;
if(StringUtils.isNotEmpty(questionExcel.getOptionC()))optionList.add( new QuestionOption(questionId,"C",questionExcel.getOptionC(),checkAnswer(questionExcel.getAnswer(),"C")) ) ;
if(StringUtils.isNotEmpty(questionExcel.getOptionD()))optionList.add( new QuestionOption(questionId,"D",questionExcel.getOptionD(),checkAnswer(questionExcel.getAnswer(),"D")) ) ;
if(StringUtils.isNotEmpty(questionExcel.getOptionE()))optionList.add( new QuestionOption(questionId,"E",questionExcel.getOptionE(),checkAnswer(questionExcel.getAnswer(),"E")) ) ;
if(StringUtils.isNotEmpty(questionExcel.getOptionF()))optionList.add( new QuestionOption(questionId,"F",questionExcel.getOptionF(),checkAnswer(questionExcel.getAnswer(),"F")) ) ;
if(StringUtils.isNotEmpty(questionExcel.getOptionG()))optionList.add( new QuestionOption(questionId,"G",questionExcel.getOptionG(),checkAnswer(questionExcel.getAnswer(),"G")) ) ;
// 将List转换为Json字符串
String questionData = gson.toJson( question.getOptionList() ) ;
question.setQuestionData( questionData ) ;
this.baseMapper.insert(question);
//批量新增
questionOptionService.saveBatch(optionList);
}
}
/* // 创建Gson实例
Gson gson = new Gson();
// 将List转换为Json字符串
String questionData = gson.toJson( question.getOptionList() ) ;
question.setQuestionData( questionData ) ;*/
}
private String checkAnswer(String answer,String option){
if(answer.toUpperCase().contains(option)){
return "1";
}
return "0" ;
}
/***
......
......@@ -56,5 +56,17 @@ public class QuestionExcel {
@ApiModelProperty(value = "试题解析")
private String analyzes;
public QuestionExcel(){
}
public QuestionExcel(String questionType, String questionTitle, String optionA, String optionB, String optionC, String optionD, String answer, String analyzes) {
this.questionType = questionType;
this.questionTitle = questionTitle;
this.optionA = optionA;
this.optionB = optionB;
this.optionC = optionC;
this.optionD = optionD;
this.answer = answer;
this.analyzes = analyzes;
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!