d83370ad 康伟

kangwei: 测试:1、考试任务下发后,被考试人在考试前应该发送消息推送,推送规则:

         (1)、任务发布时推送一次
         (2)、考试开始时间前1天推送一次
         (3)、考试结束时间前1天推送一次(如果还未完成的话)
        2、多选题少选未得分,应增加多选题少选得分规则设置功能
1 个父辈 26b388a1
......@@ -55,6 +55,31 @@ public class JSUtils {
return format(obj1,null);
}
public static String dateFormat(String time , String inputFormat,String outputFormat ){
String result = time;
try {
if(StringUtils.isEmpty(inputFormat)){
inputFormat = "yyyy-MM-dd";
}
if(StringUtils.isEmpty(outputFormat)){
outputFormat = "yyyy-MM-dd";//yyyy年MM月dd日
}
// 创建一个SimpleDateFormat对象,指定目标日期格式
SimpleDateFormat inputFormatF = new SimpleDateFormat(inputFormat);
SimpleDateFormat outputFormatF = new SimpleDateFormat(outputFormat);
// 将字符串转换为Date对象
Date date = inputFormatF.parse(time);
// 将Date对象格式化为指定的字符串格式
result = outputFormatF.format(date);
// 输出转换后的日期字符串
//System.out.println(result);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
/***
* 格式化结果,指定格式,默认保留两位小数
* @param obj1
......
......@@ -26,8 +26,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.modules.edu.vo.PaperVO;
import com.skua.modules.guest.util.DateUtil;
import com.skua.modules.system.entity.SysUser;
import com.skua.modules.system.service.ISysUserService;
import com.skua.tool.util.JSUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -157,18 +159,19 @@ public class PaperController {
boolean ok = paperService.updateById(paper);
//TODO 返回false说明什么?
if(ok) {
if("1".equals(sendStatus)){
//信息推送
String messageTitle = DateUtils.dateformat(paper.getStartTime(),"yyyy年MM月dd日")+ "考试"+paper.getPaperTitle() +",请准时参加考试";
String messageBody = DateUtils.dateformat(paper.getStartTime(),"yyyy年MM月dd日")+ "考试"+paper.getPaperTitle() +",请准时参加考试";
String messageTitle = "考试任务:"+paper.getPaperTitle() +"";// JSUtils.dateFormat( paper.getStartTime() ,null,"yyyy年MM月dd日") +
String messageBody = "考试任务:"+paper.getPaperTitle() +",考试时间:"+paper.getStartTime() +"至"+paper.getEndTime()+",请准时参加考试";
//信息推送
pushMsgNoProcess(messageTitle,messageBody,paper.getExamUserIds());
result.success("修改成功!");
}
result.success("操作成功!");
}
}
return result;
}
//信息推送
private void pushMsgNoProcess(String messageTitle ,String messageBody ,String userIds) {
if(StringUtils.isNotEmpty(userIds)){
List<SysUser> sysUserList = userService.getUserByUserIds(userIds);
......
......@@ -96,12 +96,10 @@ public class Paper {
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "多选题得分规则:1 全对得分,2 部分得分,3不得分")
@Dict(dicCode = "exam_multiple_rule")
private String multipleRule;
@ApiModelProperty(value = "开始次数")
private Integer examCount;
/**上传人*/
......
......@@ -60,8 +60,9 @@ public class EduSendMsgJob implements Job {
List<Paper> paperList = paperService.queryExamUserIds(yesterDate,null);
if(paperList != null && !paperList.isEmpty()){
for(Paper paper : paperList){
messageTitle = "明天考试"+paper.getPaperTitle() +",请参加考试";
messageBody = "明天考试"+paper.getPaperTitle() +",请参加考试";
messageTitle = "考试任务:<"+paper.getPaperTitle() +">明天开始,请参加考试";
//messageBody = "明天考试任务:"+paper.getPaperTitle() +",请参加考试";
messageBody = "考试任务:<"+paper.getPaperTitle() +">明天开始,考试时间:"+paper.getStartTime() +"至"+paper.getEndTime()+",请准时参加考试";
userIds = getNoExamUserIds(paper.getExamUserIds(),paper.getUserIds());
if(StringUtils.isNotEmpty(userIds)){
pushMsgNoProcess(messageTitle,messageBody,userIds);
......@@ -72,8 +73,9 @@ public class EduSendMsgJob implements Job {
paperList = paperService.queryExamUserIds(null,tomorrowDate);
if(paperList != null && !paperList.isEmpty()){
for(Paper paper : paperList){
messageTitle = "明天考试"+paper.getPaperTitle() +"结束,请尽快考试";
messageBody = "明天考试"+paper.getPaperTitle() +"结束,请尽快参加考试";
messageTitle = "考试任务:<"+paper.getPaperTitle() +">明天结束,请尽快考试";
//messageBody = "考试:"+paper.getPaperTitle() +"明天结束,请尽快参加考试";
messageBody = "考试任务:<"+paper.getPaperTitle() +">明天结束,考试时间:"+paper.getStartTime() +"至"+paper.getEndTime()+",请准时参加考试";
userIds = getNoExamUserIds(paper.getExamUserIds(),paper.getUserIds());
if(StringUtils.isNotEmpty(userIds)){
pushMsgNoProcess(messageTitle,messageBody,userIds);
......
......@@ -48,7 +48,7 @@
<!-- 获取考试userIds集合-->
<select id="queryMyPaperRecoredByList" resultType="com.skua.modules.edu.entity.Paper">
<select id="queryExamUserIds" resultType="com.skua.modules.edu.entity.Paper">
select aaa.userids, p.id,p.paper_title,p.exam_user_ids from edu_paper p
left join ( select up.paper_id,group_concat(up.user_id) 'userIds' from edu_user_paper up group by up.paper_id )aaa on aaa.paper_id = p.id
where p.send_status = '1'
......
......@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.edu.entity.*;
import com.skua.modules.edu.mapper.*;
import com.skua.modules.edu.service.IPaperService;
......@@ -12,6 +13,7 @@ import com.skua.modules.edu.vo.PaperVO;
import com.skua.modules.edu.vo.UserPaperVO;
import com.skua.modules.quartz.util.BaseUtil;
import com.skua.tool.util.DigitalUtils;
import com.skua.tool.util.JSUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.boot.json.GsonJsonParser;
import org.springframework.stereotype.Service;
......@@ -21,6 +23,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.List;
/**
......@@ -204,6 +207,8 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, Paper> implements
//答题卡详情
String score = "0";
String totalScore = "0";
//设置多选题部分得分分值
List<Question> questionList = questionMapper.selectListByPaperId(paperVO.getPaperId());;
if( paperVO.getAnswerList() != null ){
for(UserAnswer userAnswer : paperVO.getAnswerList()){
userAnswer.setUserPaperId( userPaper.getId());
......@@ -211,16 +216,26 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, Paper> implements
userAnswer.setUserId( userPaper.getUserId()) ;
// 答案排序
userAnswer.splitAndSort();
if(questionList != null && !questionList.isEmpty()){
for(Question question : questionList){
if(userAnswer.getQuestionId().equals(question.getId())){
score = calculateScore(question.getQuestionAnswer(),userAnswer.getAnswer(),question.getScore());
break;
}
}
}
//totalScore +=score;
userAnswer.setScore(score);
userAnswerMapper.insert( userAnswer ) ;
}
userAnswerMapper.checkAnswerByUserPaperId( userPaper.getId() );
//设置多选题部分得分分值
//userAnswerMapper.checkAnswerByUserPaperId( userPaper.getId() );
/*//设置多选题部分得分分值
if("2".equals( paper.getMultipleRule())){
userAnswerMapper.setScoreByMultiple(userPaper.getId());
}
}*/
totalScore = userPaperMapper.queryPaperScore(userPaper.getId());
}
userPaper.setScore(totalScore ) ;
userPaper.setScore(totalScore+"" ) ;
userPaperMapper.updateById( userPaper);
// 修改开始人次
......@@ -229,8 +244,53 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, Paper> implements
//计算分数
// answer.setScore( totalScore );
// answerMapper.updateById( answer ) ;
return totalScore;
return totalScore+"";
}
/* public String queryPaperScore(String paperId,String userId){
}*/
/**
* 计算多选题得分
* @param correctAnswer 正确答案字符串,例如 "ABCD"
* @param studentAnswer 学生答案字符串,例如 "ABEF"
* @param fullScore 题目满分值
* @return 学生得分
*/
public String calculateScore(String correctAnswer, String studentAnswer, String fullScore) {
if(correctAnswer.equalsIgnoreCase(studentAnswer)){
return fullScore;
}
List<Character> correctList = toCharacterList(correctAnswer);
List<Character> studentList = toCharacterList(studentAnswer);
// 计算学生答对的选项数量
int correctCount = 0;
for (Character option : studentList) {
if (correctList.contains(option)) {
correctCount++;
}
}
// 计算得分
String score;
if (correctCount == correctList.size() && correctCount == studentList.size()) {
// 完全答对
score = fullScore;
} else if (correctCount > 0) {
// 部分答对
score = ConvertUtils.getDouble(fullScore ,0d) / 2 +"";
} else {
// 完全答错
score = "0";
}
return score;
}
/**
* 将字符串转换为字符列表
* @param str 输入字符串
* @return 字符列表
*/
private List<Character> toCharacterList(String str) {
return Arrays.asList(str.chars().mapToObj(c -> (char) c).toArray(Character[]::new));
}
}
......
......@@ -25,7 +25,7 @@ public class DistributContractTempServiceImpl extends ServiceImpl<DistributContr
JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master");
//# 插入到分销合同表
String sql = "insert into erp_distribut_contract(id,depart_id,project_name,contract_name,apply_user,purchase_time,contract_year, contract_code,status,start_time,end_time,create_time)";
sql +="select id,'af880d6a13404a67825e94bc0f2f3808',project_name,contract_name,apply_user,DATE_FORMAT(purchase_time, '%Y-%m-%d'),contract_year, contract_code,status,DATE_FORMAT(start_time, '%Y-%m-%d %H:%i:%s'),DATE_FORMAT(end_time, '%Y-%m-%d %H:%i:%s') ,now() from erp_distribut_contract_temp";
sql +="select id,'af880d6a13404a67825e94bc0f2f3808',project_name,contract_name,apply_user,DATE_FORMAT(purchase_time, '%Y-%m-%d'),contract_year, contract_code,status,DATE_FORMAT(start_time, '%Y-%m-%d'),DATE_FORMAT(end_time, '%Y-%m-%d') ,now() from erp_distribut_contract_temp";
sql +=" where id in (select min(id) from erp_distribut_contract_temp group by contract_code )";
masterDB.execute(sql);
//# 修改状态
......@@ -36,7 +36,10 @@ public class DistributContractTempServiceImpl extends ServiceImpl<DistributContr
// # 插入分销物料表
sql =" insert into erp_distribut_material( id,contract_id ,depart_id, good_code,material_num,distribut_price, tax_amount, distribut_total_price) ";
sql +=" select id,id, depart_id,good_code, material_num,distribut_price, tax_amount, distribut_total_price from erp_distribut_contract_temp";
sql +=" select id,contract_code, depart_id,good_code, material_num,distribut_price, tax_amount, distribut_total_price from erp_distribut_contract_temp";
masterDB.execute(sql);
// # 修改分销合同编号
sql ="update erp_distribut_material pm , erp_distribut_contract pc set pm.contract_id = pc.id where pm.contract_id = pc.contract_code ";
masterDB.execute(sql);
//#修改部门编号
......
......@@ -24,7 +24,7 @@ public class PurchaseContractTempServiceImpl extends ServiceImpl<PurchaseContrac
//#赋值sql--统购合同创建
String sql = "";
sql = "Insert into erp_purchase_contract(id,depart_id,purchase_name,bid_inquiry_code ,purchase_type,project_time,project_name,in_warehouse_name,contract_name,contract_code,start_time ,end_time,purchase_money,create_time,status,use_flag)";
sql += " select id,depart_name,purchase_name,bid_inquiry_code ,purchase_type, DATE_FORMAT(project_time, '%Y-%m-%d'),project_name,in_warehouse_name,contract_name,contract_code,DATE_FORMAT(start_time, '%Y-%m-%d %H:%i:%s') ,DATE_FORMAT(end_time, '%Y-%m-%d %H:%i:%s'),total_price,now(),'0','0'";
sql += " select id,depart_name,purchase_name,bid_inquiry_code ,purchase_type, DATE_FORMAT(project_time, '%Y-%m-%d'),project_name,in_warehouse_name,contract_name,contract_code,DATE_FORMAT(start_time, '%Y-%m-%d') ,DATE_FORMAT(end_time, '%Y-%m-%d'),total_price,now(),'0','0'";
sql += " from erp_purchase_contract_temp where id in (select min(id) from erp_purchase_contract_temp group by contract_code )";
// commonSqlMapper.update()
masterDB.execute( sql );
......@@ -44,8 +44,12 @@ public class PurchaseContractTempServiceImpl extends ServiceImpl<PurchaseContrac
//# 插入统购合同物料信息
sql ="Insert into erp_purchase_material(id,depart_id,contract_id,sparepart_code,supplier_id,good_code,purchase_num,unit_price,total_price)";
sql +="select id,us_depart_name,id,sparepart_code,supplier_name,good_code,purchase_num,unit_price,total_price from erp_purchase_contract_temp" ;
sql +="select id,us_depart_name,contract_code,sparepart_code,supplier_name,good_code,purchase_num,unit_price,total_price from erp_purchase_contract_temp" ;
masterDB.execute( sql );
// 修改统购合同编号
sql = "update erp_purchase_material pm , erp_purchase_contract pc set pm.contract_id = pc.id where pm.contract_id = pc.contract_code ";
masterDB.update( sql );
sql =" update erp_purchase_material pm, equipment_sparepart_supplies ss ";
sql +=" set pm.sparepart_type = ss.sparepart_type, pm.sparepart_id = ss.id, pm.sparepart_name = ss.sparepart_name,pm.specification = ss.specification,pm.measuring_unit = ss.measuring_unit";
sql +=" where pm.sparepart_code = ss.sparepart_code ";
......
......@@ -190,7 +190,7 @@ public class EquipmentCenterController {
public Result<List<Map>> maintainCompleteRateDetails(ReportStatisticsDTO reportStatisticsDTO) {
Result<List<Map>> result = new Result<>();
setDepartIds(reportStatisticsDTO);
List<Map> maintainCompleteRateDetails = iProductionEquipmentService.getMaintainCompleteRateDetails(reportStatisticsDTO);
List<Map> maintainCompleteRateDetails = iProductionEquipmentService.getMaintainCompleteRateDetailsNew(reportStatisticsDTO);
result.setResult(maintainCompleteRateDetails);
result.setSuccess(true);
return result;
......
......@@ -55,6 +55,25 @@ public class ReportStatisticsDTO {
private Integer isCompany;
@ApiModelProperty(value = "去年同比开始时间")
private String lastYearStartTime;
@ApiModelProperty(value = "去年同比结束时间")
private String lastYearEndTime;
public String getLastYearStartTime() {
if(StringUtils.isEmpty(lastYearStartTime)){
lastYearStartTime = DateUtils.getTbDate(lastYearStartTime);
}
return lastYearStartTime;
}
public String getLastYearEndTime() {
if(StringUtils.isEmpty(lastYearEndTime)){
lastYearEndTime = DateUtils.getTbDate(lastYearEndTime);
}
return lastYearEndTime;
}
public String getTime() {
if(StringUtils.isEmpty(time)){//判断time如果为空,获取starttime的年份数据,否则获取当前年
if( StringUtils.isNotEmpty(startTime) ){
......
......@@ -191,4 +191,6 @@ public interface ProductionEquipmentMapper {
List<Map> getContrastCostDetails(ReportStatisticsDTO reportStatisticsDTO);
//设备完好率详情(新)
List<Map> getEquipmentIntactRateDetailsNew(ReportStatisticsDTO reportStatisticsDTO);
//完成率详情
List<Map> getMaintainCompleteRateDetails(ReportStatisticsDTO reportStatisticsDTO);
}
......
......@@ -1014,7 +1014,7 @@
SELECT IFNULL(SUM(SUBSTRING(eor.run_time, 1, 2)), 0) / 24 AS runTime,
sd.depart_name AS departName,sd.id as departId
FROM equipment_operation_record eor
LEFT JOIN sys_depart sd ON eor.depart_id = sd.id
LEFT JOIN sys_depart sd ON eor.factory_id = sd.id
WHERE (eor.del_flag IS NULL OR eor.del_flag = 0)
AND SUBSTRING(eor.create_time, 1, 7) = #{time}
AND sd.parent_id = #{companyId}
......@@ -1026,7 +1026,7 @@
sd1.depart_name AS departName,
sd1.id as departId
FROM equipment_operation_record eor
LEFT JOIN sys_depart sd ON eor.depart_id = sd.id
LEFT JOIN sys_depart sd ON eor.factory_id = sd.id
LEFT JOIN sys_depart sd1 ON sd1.id = sd.parent_id
WHERE (eor.del_flag IS NULL OR eor.del_flag = 0)
AND SUBSTRING(eor.create_time, 1, 7) = #{time}
......@@ -1039,7 +1039,7 @@
sd.depart_name AS departName,
sd.id as departId
FROM equipment_operation_record eor
LEFT JOIN sys_depart sd ON eor.depart_id = sd.id
LEFT JOIN sys_depart sd ON eor.factory_id = sd.id
WHERE (eor.del_flag IS NULL OR eor.del_flag = 0)
AND SUBSTRING(eor.create_time, 1, 7) = #{time}
AND sd.id = #{companyId}
......@@ -1270,4 +1270,32 @@ FROM
AND sd.id = #{companyId}
GROUP BY sd.id
</select>
<!-- 完成率详情-->
<select id="getMaintainCompleteRateDetails" parameterType="com.skua.modules.equipment.dto.ReportStatisticsDTO" resultType="java.util.Map">
select d.id depart_id , d.depart_name 'departName' ,
round(ifnull(aaa.completeNum/aaa.planNum*100,0),2) 'complete',
round(ifnull(bbb.completeNum/bbb.planNum*100,0),2) 'lastYearComplete'
from sys_depart d
left join (
select emt.depart_id, count(emt.id) 'planNum' ,
ifnull( SUM( CASE WHEN emt.results_enforcement >2 THEN 1 ELSE 0 END ),0) as completeNum
from equipment_maintain_task emt
where emt.del_flag = 0 and emt.maintain_time &gt; #{startTime} and emt.maintain_time &lt;= #{endTime}
group by emt.depart_id
)aaa on aaa.depart_id = d.id
left join (
select emt.depart_id, count(emt.id) 'planNum' ,
ifnull( SUM( CASE WHEN emt.results_enforcement >2 THEN 1 ELSE 0 END ),0) as completeNum
from equipment_maintain_task emt
where emt.del_flag = 0 and LEFT( emt.maintain_time, 10 ) &gt; #{lastYearStartTime} and LEFT( emt.maintain_time, 10 ) &lt;= #{lastYearEndTime}
group by emt.depart_id
)bbb on bbb.depart_id = d.id
where d.depart_type = 1
<if test="departIds != null ">
and d.id in (${departIds})
</if>
</select>
</mapper>
......
......@@ -53,8 +53,14 @@ public interface IProductionEquipmentService {
//维护完成率趋势
List<ContrastVO> getMaintainCompleteRate(ReportStatisticsDTO reportStatisticsDTO);
//维护完成率趋势详情
List<Map> getMaintainCompleteRateDetails(ReportStatisticsDTO reportStatisticsDTO);
/***
* 完成率详情(新)
* @param reportStatisticsDTO
* @return
*/
public List<Map> getMaintainCompleteRateDetailsNew(ReportStatisticsDTO reportStatisticsDTO);
//维修维护费用对比
List<ContrastVO> getContrastCost(ReportStatisticsDTO reportStatisticsDTO);
......
......@@ -637,7 +637,7 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
//平均修复时间
List<Map> MTTR = new ArrayList<>();
if (reportStatisticsDTO.getTimeUnit() == 6) {
MTBF = productionEquipmentMapper.getHalfIntactMTBF();
MTBF = productionEquipmentMapper.getHalfIntactMTBF(); //平均故障时间
MTTR = productionEquipmentMapper.getHalfIntactMTTR();
} else {
MTBF = productionEquipmentMapper.getOneYearMTBF();
......@@ -828,6 +828,14 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
return contrastVOS;
}
/***
* 完成率详情
* @param reportStatisticsDTO
* @return
*/
public List<Map> getMaintainCompleteRateDetailsNew(ReportStatisticsDTO reportStatisticsDTO) {
return productionEquipmentMapper.getMaintainCompleteRateDetails(reportStatisticsDTO);
}
@Override
public List<Map> getMaintainCompleteRateDetails(ReportStatisticsDTO reportStatisticsDTO) {
List<Map> list = new ArrayList<>();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!