d83370ad 康伟

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

         (1)、任务发布时推送一次
         (2)、考试开始时间前1天推送一次
         (3)、考试结束时间前1天推送一次(如果还未完成的话)
        2、多选题少选未得分,应增加多选题少选得分规则设置功能
1 个父辈 26b388a1
...@@ -55,6 +55,31 @@ public class JSUtils { ...@@ -55,6 +55,31 @@ public class JSUtils {
55 return format(obj1,null); 55 return format(obj1,null);
56 } 56 }
57 57
58
59 public static String dateFormat(String time , String inputFormat,String outputFormat ){
60 String result = time;
61 try {
62 if(StringUtils.isEmpty(inputFormat)){
63 inputFormat = "yyyy-MM-dd";
64 }
65 if(StringUtils.isEmpty(outputFormat)){
66 outputFormat = "yyyy-MM-dd";//yyyy年MM月dd日
67 }
68 // 创建一个SimpleDateFormat对象,指定目标日期格式
69 SimpleDateFormat inputFormatF = new SimpleDateFormat(inputFormat);
70 SimpleDateFormat outputFormatF = new SimpleDateFormat(outputFormat);
71 // 将字符串转换为Date对象
72 Date date = inputFormatF.parse(time);
73 // 将Date对象格式化为指定的字符串格式
74 result = outputFormatF.format(date);
75 // 输出转换后的日期字符串
76 //System.out.println(result);
77 } catch (Exception e) {
78 e.printStackTrace();
79 }
80 return result;
81 }
82
58 /*** 83 /***
59 * 格式化结果,指定格式,默认保留两位小数 84 * 格式化结果,指定格式,默认保留两位小数
60 * @param obj1 85 * @param obj1
......
...@@ -26,8 +26,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -26,8 +26,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
26 import com.baomidou.mybatisplus.core.metadata.IPage; 26 import com.baomidou.mybatisplus.core.metadata.IPage;
27 import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 27 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
28 import com.skua.modules.edu.vo.PaperVO; 28 import com.skua.modules.edu.vo.PaperVO;
29 import com.skua.modules.guest.util.DateUtil;
29 import com.skua.modules.system.entity.SysUser; 30 import com.skua.modules.system.entity.SysUser;
30 import com.skua.modules.system.service.ISysUserService; 31 import com.skua.modules.system.service.ISysUserService;
32 import com.skua.tool.util.JSUtils;
31 import lombok.extern.slf4j.Slf4j; 33 import lombok.extern.slf4j.Slf4j;
32 34
33 import org.apache.commons.lang3.StringUtils; 35 import org.apache.commons.lang3.StringUtils;
...@@ -157,18 +159,19 @@ public class PaperController { ...@@ -157,18 +159,19 @@ public class PaperController {
157 boolean ok = paperService.updateById(paper); 159 boolean ok = paperService.updateById(paper);
158 //TODO 返回false说明什么? 160 //TODO 返回false说明什么?
159 if(ok) { 161 if(ok) {
160 162 if("1".equals(sendStatus)){
161 //信息推送 163 //信息推送
162 String messageTitle = DateUtils.dateformat(paper.getStartTime(),"yyyy年MM月dd日")+ "考试"+paper.getPaperTitle() +",请准时参加考试"; 164 String messageTitle = "考试任务:"+paper.getPaperTitle() +"";// JSUtils.dateFormat( paper.getStartTime() ,null,"yyyy年MM月dd日") +
163 String messageBody = DateUtils.dateformat(paper.getStartTime(),"yyyy年MM月dd日")+ "考试"+paper.getPaperTitle() +",请准时参加考试"; 165 String messageBody = "考试任务:"+paper.getPaperTitle() +",考试时间:"+paper.getStartTime() +"至"+paper.getEndTime()+",请准时参加考试";
164 //信息推送 166 //信息推送
165 pushMsgNoProcess(messageTitle,messageBody,paper.getExamUserIds()); 167 pushMsgNoProcess(messageTitle,messageBody,paper.getExamUserIds());
166 result.success("修改成功!"); 168 }
169 result.success("操作成功!");
167 } 170 }
168 } 171 }
169 return result; 172 return result;
170 } 173 }
171 174 //信息推送
172 private void pushMsgNoProcess(String messageTitle ,String messageBody ,String userIds) { 175 private void pushMsgNoProcess(String messageTitle ,String messageBody ,String userIds) {
173 if(StringUtils.isNotEmpty(userIds)){ 176 if(StringUtils.isNotEmpty(userIds)){
174 List<SysUser> sysUserList = userService.getUserByUserIds(userIds); 177 List<SysUser> sysUserList = userService.getUserByUserIds(userIds);
......
...@@ -96,12 +96,10 @@ public class Paper { ...@@ -96,12 +96,10 @@ public class Paper {
96 @ApiModelProperty(value = "备注") 96 @ApiModelProperty(value = "备注")
97 private String remark; 97 private String remark;
98 98
99
100 @ApiModelProperty(value = "多选题得分规则:1 全对得分,2 部分得分,3不得分") 99 @ApiModelProperty(value = "多选题得分规则:1 全对得分,2 部分得分,3不得分")
101 @Dict(dicCode = "exam_multiple_rule") 100 @Dict(dicCode = "exam_multiple_rule")
102 private String multipleRule; 101 private String multipleRule;
103 102
104
105 @ApiModelProperty(value = "开始次数") 103 @ApiModelProperty(value = "开始次数")
106 private Integer examCount; 104 private Integer examCount;
107 /**上传人*/ 105 /**上传人*/
......
...@@ -24,7 +24,7 @@ import org.jeecgframework.poi.excel.annotation.Excel; ...@@ -24,7 +24,7 @@ import org.jeecgframework.poi.excel.annotation.Excel;
24 @Accessors(chain = true) 24 @Accessors(chain = true)
25 @ApiModel(value="edu_paper_question对象", description="在线考试--试卷试题表") 25 @ApiModel(value="edu_paper_question对象", description="在线考试--试卷试题表")
26 public class PaperQuestion { 26 public class PaperQuestion {
27 27
28 /**主键*/ 28 /**主键*/
29 @TableId(type = IdType.ID_WORKER_STR) 29 @TableId(type = IdType.ID_WORKER_STR)
30 @ApiModelProperty(value = "主键") 30 @ApiModelProperty(value = "主键")
......
...@@ -26,7 +26,7 @@ import org.jeecgframework.poi.excel.annotation.Excel; ...@@ -26,7 +26,7 @@ import org.jeecgframework.poi.excel.annotation.Excel;
26 @Accessors(chain = true) 26 @Accessors(chain = true)
27 @ApiModel(value="edu_user_answer对象", description="用户答题卡记录") 27 @ApiModel(value="edu_user_answer对象", description="用户答题卡记录")
28 public class UserAnswer { 28 public class UserAnswer {
29 29
30 /**主键*/ 30 /**主键*/
31 @TableId(type = IdType.ID_WORKER_STR) 31 @TableId(type = IdType.ID_WORKER_STR)
32 @ApiModelProperty(value = "主键") 32 @ApiModelProperty(value = "主键")
......
...@@ -60,8 +60,9 @@ public class EduSendMsgJob implements Job { ...@@ -60,8 +60,9 @@ public class EduSendMsgJob implements Job {
60 List<Paper> paperList = paperService.queryExamUserIds(yesterDate,null); 60 List<Paper> paperList = paperService.queryExamUserIds(yesterDate,null);
61 if(paperList != null && !paperList.isEmpty()){ 61 if(paperList != null && !paperList.isEmpty()){
62 for(Paper paper : paperList){ 62 for(Paper paper : paperList){
63 messageTitle = "明天考试"+paper.getPaperTitle() +",请参加考试"; 63 messageTitle = "考试任务:<"+paper.getPaperTitle() +">明天开始,请参加考试";
64 messageBody = "明天考试"+paper.getPaperTitle() +",请参加考试"; 64 //messageBody = "明天考试任务:"+paper.getPaperTitle() +",请参加考试";
65 messageBody = "考试任务:<"+paper.getPaperTitle() +">明天开始,考试时间:"+paper.getStartTime() +"至"+paper.getEndTime()+",请准时参加考试";
65 userIds = getNoExamUserIds(paper.getExamUserIds(),paper.getUserIds()); 66 userIds = getNoExamUserIds(paper.getExamUserIds(),paper.getUserIds());
66 if(StringUtils.isNotEmpty(userIds)){ 67 if(StringUtils.isNotEmpty(userIds)){
67 pushMsgNoProcess(messageTitle,messageBody,userIds); 68 pushMsgNoProcess(messageTitle,messageBody,userIds);
...@@ -72,8 +73,9 @@ public class EduSendMsgJob implements Job { ...@@ -72,8 +73,9 @@ public class EduSendMsgJob implements Job {
72 paperList = paperService.queryExamUserIds(null,tomorrowDate); 73 paperList = paperService.queryExamUserIds(null,tomorrowDate);
73 if(paperList != null && !paperList.isEmpty()){ 74 if(paperList != null && !paperList.isEmpty()){
74 for(Paper paper : paperList){ 75 for(Paper paper : paperList){
75 messageTitle = "明天考试"+paper.getPaperTitle() +"结束,请尽快考试"; 76 messageTitle = "考试任务:<"+paper.getPaperTitle() +">明天结束,请尽快考试";
76 messageBody = "明天考试"+paper.getPaperTitle() +"结束,请尽快参加考试"; 77 //messageBody = "考试:"+paper.getPaperTitle() +"明天结束,请尽快参加考试";
78 messageBody = "考试任务:<"+paper.getPaperTitle() +">明天结束,考试时间:"+paper.getStartTime() +"至"+paper.getEndTime()+",请准时参加考试";
77 userIds = getNoExamUserIds(paper.getExamUserIds(),paper.getUserIds()); 79 userIds = getNoExamUserIds(paper.getExamUserIds(),paper.getUserIds());
78 if(StringUtils.isNotEmpty(userIds)){ 80 if(StringUtils.isNotEmpty(userIds)){
79 pushMsgNoProcess(messageTitle,messageBody,userIds); 81 pushMsgNoProcess(messageTitle,messageBody,userIds);
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
48 48
49 49
50 <!-- 获取考试userIds集合--> 50 <!-- 获取考试userIds集合-->
51 <select id="queryMyPaperRecoredByList" resultType="com.skua.modules.edu.entity.Paper"> 51 <select id="queryExamUserIds" resultType="com.skua.modules.edu.entity.Paper">
52 select aaa.userids, p.id,p.paper_title,p.exam_user_ids from edu_paper p 52 select aaa.userids, p.id,p.paper_title,p.exam_user_ids from edu_paper p
53 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 53 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
54 where p.send_status = '1' 54 where p.send_status = '1'
......
...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5 import com.google.gson.Gson; 5 import com.google.gson.Gson;
6 import com.google.gson.reflect.TypeToken; 6 import com.google.gson.reflect.TypeToken;
7 import com.skua.core.context.BaseContextHandler; 7 import com.skua.core.context.BaseContextHandler;
8 import com.skua.core.util.ConvertUtils;
8 import com.skua.modules.edu.entity.*; 9 import com.skua.modules.edu.entity.*;
9 import com.skua.modules.edu.mapper.*; 10 import com.skua.modules.edu.mapper.*;
10 import com.skua.modules.edu.service.IPaperService; 11 import com.skua.modules.edu.service.IPaperService;
...@@ -12,6 +13,7 @@ import com.skua.modules.edu.vo.PaperVO; ...@@ -12,6 +13,7 @@ import com.skua.modules.edu.vo.PaperVO;
12 import com.skua.modules.edu.vo.UserPaperVO; 13 import com.skua.modules.edu.vo.UserPaperVO;
13 import com.skua.modules.quartz.util.BaseUtil; 14 import com.skua.modules.quartz.util.BaseUtil;
14 import com.skua.tool.util.DigitalUtils; 15 import com.skua.tool.util.DigitalUtils;
16 import com.skua.tool.util.JSUtils;
15 import org.springframework.beans.BeanUtils; 17 import org.springframework.beans.BeanUtils;
16 import org.springframework.boot.json.GsonJsonParser; 18 import org.springframework.boot.json.GsonJsonParser;
17 import org.springframework.stereotype.Service; 19 import org.springframework.stereotype.Service;
...@@ -21,6 +23,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -21,6 +23,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
21 import javax.annotation.Resource; 23 import javax.annotation.Resource;
22 import javax.transaction.Transactional; 24 import javax.transaction.Transactional;
23 import java.lang.reflect.Type; 25 import java.lang.reflect.Type;
26 import java.util.Arrays;
24 import java.util.List; 27 import java.util.List;
25 28
26 /** 29 /**
...@@ -204,6 +207,8 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, Paper> implements ...@@ -204,6 +207,8 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, Paper> implements
204 //答题卡详情 207 //答题卡详情
205 String score = "0"; 208 String score = "0";
206 String totalScore = "0"; 209 String totalScore = "0";
210 //设置多选题部分得分分值
211 List<Question> questionList = questionMapper.selectListByPaperId(paperVO.getPaperId());;
207 if( paperVO.getAnswerList() != null ){ 212 if( paperVO.getAnswerList() != null ){
208 for(UserAnswer userAnswer : paperVO.getAnswerList()){ 213 for(UserAnswer userAnswer : paperVO.getAnswerList()){
209 userAnswer.setUserPaperId( userPaper.getId()); 214 userAnswer.setUserPaperId( userPaper.getId());
...@@ -211,16 +216,26 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, Paper> implements ...@@ -211,16 +216,26 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, Paper> implements
211 userAnswer.setUserId( userPaper.getUserId()) ; 216 userAnswer.setUserId( userPaper.getUserId()) ;
212 // 答案排序 217 // 答案排序
213 userAnswer.splitAndSort(); 218 userAnswer.splitAndSort();
219 if(questionList != null && !questionList.isEmpty()){
220 for(Question question : questionList){
221 if(userAnswer.getQuestionId().equals(question.getId())){
222 score = calculateScore(question.getQuestionAnswer(),userAnswer.getAnswer(),question.getScore());
223 break;
224 }
225 }
226 }
227 //totalScore +=score;
228 userAnswer.setScore(score);
214 userAnswerMapper.insert( userAnswer ) ; 229 userAnswerMapper.insert( userAnswer ) ;
215 } 230 }
216 userAnswerMapper.checkAnswerByUserPaperId( userPaper.getId() ); 231 //userAnswerMapper.checkAnswerByUserPaperId( userPaper.getId() );
217 //设置多选题部分得分分值 232 /*//设置多选题部分得分分值
218 if("2".equals( paper.getMultipleRule())){ 233 if("2".equals( paper.getMultipleRule())){
219 userAnswerMapper.setScoreByMultiple(userPaper.getId()); 234 userAnswerMapper.setScoreByMultiple(userPaper.getId());
220 } 235 }*/
221 totalScore = userPaperMapper.queryPaperScore(userPaper.getId()); 236 totalScore = userPaperMapper.queryPaperScore(userPaper.getId());
222 } 237 }
223 userPaper.setScore(totalScore ) ; 238 userPaper.setScore(totalScore+"" ) ;
224 userPaperMapper.updateById( userPaper); 239 userPaperMapper.updateById( userPaper);
225 240
226 // 修改开始人次 241 // 修改开始人次
...@@ -229,8 +244,53 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, Paper> implements ...@@ -229,8 +244,53 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, Paper> implements
229 //计算分数 244 //计算分数
230 // answer.setScore( totalScore ); 245 // answer.setScore( totalScore );
231 // answerMapper.updateById( answer ) ; 246 // answerMapper.updateById( answer ) ;
232 return totalScore; 247 return totalScore+"";
233 } 248 }
234 /* public String queryPaperScore(String paperId,String userId){ 249 /* public String queryPaperScore(String paperId,String userId){
235 }*/ 250 }*/
251
252
253 /**
254 * 计算多选题得分
255 * @param correctAnswer 正确答案字符串,例如 "ABCD"
256 * @param studentAnswer 学生答案字符串,例如 "ABEF"
257 * @param fullScore 题目满分值
258 * @return 学生得分
259 */
260 public String calculateScore(String correctAnswer, String studentAnswer, String fullScore) {
261 if(correctAnswer.equalsIgnoreCase(studentAnswer)){
262 return fullScore;
263 }
264
265 List<Character> correctList = toCharacterList(correctAnswer);
266 List<Character> studentList = toCharacterList(studentAnswer);
267 // 计算学生答对的选项数量
268 int correctCount = 0;
269 for (Character option : studentList) {
270 if (correctList.contains(option)) {
271 correctCount++;
272 }
273 }
274 // 计算得分
275 String score;
276 if (correctCount == correctList.size() && correctCount == studentList.size()) {
277 // 完全答对
278 score = fullScore;
279 } else if (correctCount > 0) {
280 // 部分答对
281 score = ConvertUtils.getDouble(fullScore ,0d) / 2 +"";
282 } else {
283 // 完全答错
284 score = "0";
285 }
286 return score;
287 }
288 /**
289 * 将字符串转换为字符列表
290 * @param str 输入字符串
291 * @return 字符列表
292 */
293 private List<Character> toCharacterList(String str) {
294 return Arrays.asList(str.chars().mapToObj(c -> (char) c).toArray(Character[]::new));
295 }
236 } 296 }
......
...@@ -25,7 +25,7 @@ public class DistributContractTempServiceImpl extends ServiceImpl<DistributContr ...@@ -25,7 +25,7 @@ public class DistributContractTempServiceImpl extends ServiceImpl<DistributContr
25 JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master"); 25 JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master");
26 //# 插入到分销合同表 26 //# 插入到分销合同表
27 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)"; 27 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)";
28 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"; 28 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";
29 sql +=" where id in (select min(id) from erp_distribut_contract_temp group by contract_code )"; 29 sql +=" where id in (select min(id) from erp_distribut_contract_temp group by contract_code )";
30 masterDB.execute(sql); 30 masterDB.execute(sql);
31 //# 修改状态 31 //# 修改状态
...@@ -36,7 +36,10 @@ public class DistributContractTempServiceImpl extends ServiceImpl<DistributContr ...@@ -36,7 +36,10 @@ public class DistributContractTempServiceImpl extends ServiceImpl<DistributContr
36 36
37 // # 插入分销物料表 37 // # 插入分销物料表
38 sql =" insert into erp_distribut_material( id,contract_id ,depart_id, good_code,material_num,distribut_price, tax_amount, distribut_total_price) "; 38 sql =" insert into erp_distribut_material( id,contract_id ,depart_id, good_code,material_num,distribut_price, tax_amount, distribut_total_price) ";
39 sql +=" select id,id, depart_id,good_code, material_num,distribut_price, tax_amount, distribut_total_price from erp_distribut_contract_temp"; 39 sql +=" select id,contract_code, depart_id,good_code, material_num,distribut_price, tax_amount, distribut_total_price from erp_distribut_contract_temp";
40 masterDB.execute(sql);
41 // # 修改分销合同编号
42 sql ="update erp_distribut_material pm , erp_distribut_contract pc set pm.contract_id = pc.id where pm.contract_id = pc.contract_code ";
40 masterDB.execute(sql); 43 masterDB.execute(sql);
41 44
42 //#修改部门编号 45 //#修改部门编号
......
...@@ -24,7 +24,7 @@ public class PurchaseContractTempServiceImpl extends ServiceImpl<PurchaseContrac ...@@ -24,7 +24,7 @@ public class PurchaseContractTempServiceImpl extends ServiceImpl<PurchaseContrac
24 //#赋值sql--统购合同创建 24 //#赋值sql--统购合同创建
25 String sql = ""; 25 String sql = "";
26 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)"; 26 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)";
27 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'"; 27 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'";
28 sql += " from erp_purchase_contract_temp where id in (select min(id) from erp_purchase_contract_temp group by contract_code )"; 28 sql += " from erp_purchase_contract_temp where id in (select min(id) from erp_purchase_contract_temp group by contract_code )";
29 // commonSqlMapper.update() 29 // commonSqlMapper.update()
30 masterDB.execute( sql ); 30 masterDB.execute( sql );
...@@ -44,8 +44,12 @@ public class PurchaseContractTempServiceImpl extends ServiceImpl<PurchaseContrac ...@@ -44,8 +44,12 @@ public class PurchaseContractTempServiceImpl extends ServiceImpl<PurchaseContrac
44 44
45 //# 插入统购合同物料信息 45 //# 插入统购合同物料信息
46 sql ="Insert into erp_purchase_material(id,depart_id,contract_id,sparepart_code,supplier_id,good_code,purchase_num,unit_price,total_price)"; 46 sql ="Insert into erp_purchase_material(id,depart_id,contract_id,sparepart_code,supplier_id,good_code,purchase_num,unit_price,total_price)";
47 sql +="select id,us_depart_name,id,sparepart_code,supplier_name,good_code,purchase_num,unit_price,total_price from erp_purchase_contract_temp" ; 47 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" ;
48 masterDB.execute( sql ); 48 masterDB.execute( sql );
49 // 修改统购合同编号
50 sql = "update erp_purchase_material pm , erp_purchase_contract pc set pm.contract_id = pc.id where pm.contract_id = pc.contract_code ";
51 masterDB.update( sql );
52
49 sql =" update erp_purchase_material pm, equipment_sparepart_supplies ss "; 53 sql =" update erp_purchase_material pm, equipment_sparepart_supplies ss ";
50 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"; 54 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";
51 sql +=" where pm.sparepart_code = ss.sparepart_code "; 55 sql +=" where pm.sparepart_code = ss.sparepart_code ";
......
...@@ -190,7 +190,7 @@ public class EquipmentCenterController { ...@@ -190,7 +190,7 @@ public class EquipmentCenterController {
190 public Result<List<Map>> maintainCompleteRateDetails(ReportStatisticsDTO reportStatisticsDTO) { 190 public Result<List<Map>> maintainCompleteRateDetails(ReportStatisticsDTO reportStatisticsDTO) {
191 Result<List<Map>> result = new Result<>(); 191 Result<List<Map>> result = new Result<>();
192 setDepartIds(reportStatisticsDTO); 192 setDepartIds(reportStatisticsDTO);
193 List<Map> maintainCompleteRateDetails = iProductionEquipmentService.getMaintainCompleteRateDetails(reportStatisticsDTO); 193 List<Map> maintainCompleteRateDetails = iProductionEquipmentService.getMaintainCompleteRateDetailsNew(reportStatisticsDTO);
194 result.setResult(maintainCompleteRateDetails); 194 result.setResult(maintainCompleteRateDetails);
195 result.setSuccess(true); 195 result.setSuccess(true);
196 return result; 196 return result;
......
...@@ -55,6 +55,25 @@ public class ReportStatisticsDTO { ...@@ -55,6 +55,25 @@ public class ReportStatisticsDTO {
55 private Integer isCompany; 55 private Integer isCompany;
56 56
57 57
58 @ApiModelProperty(value = "去年同比开始时间")
59 private String lastYearStartTime;
60 @ApiModelProperty(value = "去年同比结束时间")
61 private String lastYearEndTime;
62
63 public String getLastYearStartTime() {
64 if(StringUtils.isEmpty(lastYearStartTime)){
65 lastYearStartTime = DateUtils.getTbDate(lastYearStartTime);
66 }
67 return lastYearStartTime;
68 }
69
70 public String getLastYearEndTime() {
71 if(StringUtils.isEmpty(lastYearEndTime)){
72 lastYearEndTime = DateUtils.getTbDate(lastYearEndTime);
73 }
74 return lastYearEndTime;
75 }
76
58 public String getTime() { 77 public String getTime() {
59 if(StringUtils.isEmpty(time)){//判断time如果为空,获取starttime的年份数据,否则获取当前年 78 if(StringUtils.isEmpty(time)){//判断time如果为空,获取starttime的年份数据,否则获取当前年
60 if( StringUtils.isNotEmpty(startTime) ){ 79 if( StringUtils.isNotEmpty(startTime) ){
......
...@@ -191,4 +191,6 @@ public interface ProductionEquipmentMapper { ...@@ -191,4 +191,6 @@ public interface ProductionEquipmentMapper {
191 List<Map> getContrastCostDetails(ReportStatisticsDTO reportStatisticsDTO); 191 List<Map> getContrastCostDetails(ReportStatisticsDTO reportStatisticsDTO);
192 //设备完好率详情(新) 192 //设备完好率详情(新)
193 List<Map> getEquipmentIntactRateDetailsNew(ReportStatisticsDTO reportStatisticsDTO); 193 List<Map> getEquipmentIntactRateDetailsNew(ReportStatisticsDTO reportStatisticsDTO);
194 //完成率详情
195 List<Map> getMaintainCompleteRateDetails(ReportStatisticsDTO reportStatisticsDTO);
194 } 196 }
......
...@@ -1014,7 +1014,7 @@ ...@@ -1014,7 +1014,7 @@
1014 SELECT IFNULL(SUM(SUBSTRING(eor.run_time, 1, 2)), 0) / 24 AS runTime, 1014 SELECT IFNULL(SUM(SUBSTRING(eor.run_time, 1, 2)), 0) / 24 AS runTime,
1015 sd.depart_name AS departName,sd.id as departId 1015 sd.depart_name AS departName,sd.id as departId
1016 FROM equipment_operation_record eor 1016 FROM equipment_operation_record eor
1017 LEFT JOIN sys_depart sd ON eor.depart_id = sd.id 1017 LEFT JOIN sys_depart sd ON eor.factory_id = sd.id
1018 WHERE (eor.del_flag IS NULL OR eor.del_flag = 0) 1018 WHERE (eor.del_flag IS NULL OR eor.del_flag = 0)
1019 AND SUBSTRING(eor.create_time, 1, 7) = #{time} 1019 AND SUBSTRING(eor.create_time, 1, 7) = #{time}
1020 AND sd.parent_id = #{companyId} 1020 AND sd.parent_id = #{companyId}
...@@ -1026,7 +1026,7 @@ ...@@ -1026,7 +1026,7 @@
1026 sd1.depart_name AS departName, 1026 sd1.depart_name AS departName,
1027 sd1.id as departId 1027 sd1.id as departId
1028 FROM equipment_operation_record eor 1028 FROM equipment_operation_record eor
1029 LEFT JOIN sys_depart sd ON eor.depart_id = sd.id 1029 LEFT JOIN sys_depart sd ON eor.factory_id = sd.id
1030 LEFT JOIN sys_depart sd1 ON sd1.id = sd.parent_id 1030 LEFT JOIN sys_depart sd1 ON sd1.id = sd.parent_id
1031 WHERE (eor.del_flag IS NULL OR eor.del_flag = 0) 1031 WHERE (eor.del_flag IS NULL OR eor.del_flag = 0)
1032 AND SUBSTRING(eor.create_time, 1, 7) = #{time} 1032 AND SUBSTRING(eor.create_time, 1, 7) = #{time}
...@@ -1039,7 +1039,7 @@ ...@@ -1039,7 +1039,7 @@
1039 sd.depart_name AS departName, 1039 sd.depart_name AS departName,
1040 sd.id as departId 1040 sd.id as departId
1041 FROM equipment_operation_record eor 1041 FROM equipment_operation_record eor
1042 LEFT JOIN sys_depart sd ON eor.depart_id = sd.id 1042 LEFT JOIN sys_depart sd ON eor.factory_id = sd.id
1043 WHERE (eor.del_flag IS NULL OR eor.del_flag = 0) 1043 WHERE (eor.del_flag IS NULL OR eor.del_flag = 0)
1044 AND SUBSTRING(eor.create_time, 1, 7) = #{time} 1044 AND SUBSTRING(eor.create_time, 1, 7) = #{time}
1045 AND sd.id = #{companyId} 1045 AND sd.id = #{companyId}
...@@ -1270,4 +1270,32 @@ FROM ...@@ -1270,4 +1270,32 @@ FROM
1270 AND sd.id = #{companyId} 1270 AND sd.id = #{companyId}
1271 GROUP BY sd.id 1271 GROUP BY sd.id
1272 </select> 1272 </select>
1273
1274 <!-- 完成率详情-->
1275 <select id="getMaintainCompleteRateDetails" parameterType="com.skua.modules.equipment.dto.ReportStatisticsDTO" resultType="java.util.Map">
1276 select d.id depart_id , d.depart_name 'departName' ,
1277 round(ifnull(aaa.completeNum/aaa.planNum*100,0),2) 'complete',
1278 round(ifnull(bbb.completeNum/bbb.planNum*100,0),2) 'lastYearComplete'
1279 from sys_depart d
1280 left join (
1281 select emt.depart_id, count(emt.id) 'planNum' ,
1282 ifnull( SUM( CASE WHEN emt.results_enforcement >2 THEN 1 ELSE 0 END ),0) as completeNum
1283 from equipment_maintain_task emt
1284 where emt.del_flag = 0 and emt.maintain_time &gt; #{startTime} and emt.maintain_time &lt;= #{endTime}
1285 group by emt.depart_id
1286 )aaa on aaa.depart_id = d.id
1287
1288 left join (
1289 select emt.depart_id, count(emt.id) 'planNum' ,
1290 ifnull( SUM( CASE WHEN emt.results_enforcement >2 THEN 1 ELSE 0 END ),0) as completeNum
1291 from equipment_maintain_task emt
1292 where emt.del_flag = 0 and LEFT( emt.maintain_time, 10 ) &gt; #{lastYearStartTime} and LEFT( emt.maintain_time, 10 ) &lt;= #{lastYearEndTime}
1293 group by emt.depart_id
1294 )bbb on bbb.depart_id = d.id
1295 where d.depart_type = 1
1296 <if test="departIds != null ">
1297 and d.id in (${departIds})
1298 </if>
1299
1300 </select>
1273 </mapper> 1301 </mapper>
......
...@@ -53,8 +53,14 @@ public interface IProductionEquipmentService { ...@@ -53,8 +53,14 @@ public interface IProductionEquipmentService {
53 53
54 //维护完成率趋势 54 //维护完成率趋势
55 List<ContrastVO> getMaintainCompleteRate(ReportStatisticsDTO reportStatisticsDTO); 55 List<ContrastVO> getMaintainCompleteRate(ReportStatisticsDTO reportStatisticsDTO);
56 56 //维护完成率趋势详情
57 List<Map> getMaintainCompleteRateDetails(ReportStatisticsDTO reportStatisticsDTO); 57 List<Map> getMaintainCompleteRateDetails(ReportStatisticsDTO reportStatisticsDTO);
58 /***
59 * 完成率详情(新)
60 * @param reportStatisticsDTO
61 * @return
62 */
63 public List<Map> getMaintainCompleteRateDetailsNew(ReportStatisticsDTO reportStatisticsDTO);
58 64
59 //维修维护费用对比 65 //维修维护费用对比
60 List<ContrastVO> getContrastCost(ReportStatisticsDTO reportStatisticsDTO); 66 List<ContrastVO> getContrastCost(ReportStatisticsDTO reportStatisticsDTO);
......
...@@ -637,7 +637,7 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi ...@@ -637,7 +637,7 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
637 //平均修复时间 637 //平均修复时间
638 List<Map> MTTR = new ArrayList<>(); 638 List<Map> MTTR = new ArrayList<>();
639 if (reportStatisticsDTO.getTimeUnit() == 6) { 639 if (reportStatisticsDTO.getTimeUnit() == 6) {
640 MTBF = productionEquipmentMapper.getHalfIntactMTBF(); 640 MTBF = productionEquipmentMapper.getHalfIntactMTBF(); //平均故障时间
641 MTTR = productionEquipmentMapper.getHalfIntactMTTR(); 641 MTTR = productionEquipmentMapper.getHalfIntactMTTR();
642 } else { 642 } else {
643 MTBF = productionEquipmentMapper.getOneYearMTBF(); 643 MTBF = productionEquipmentMapper.getOneYearMTBF();
...@@ -828,6 +828,14 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi ...@@ -828,6 +828,14 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
828 return contrastVOS; 828 return contrastVOS;
829 } 829 }
830 830
831 /***
832 * 完成率详情
833 * @param reportStatisticsDTO
834 * @return
835 */
836 public List<Map> getMaintainCompleteRateDetailsNew(ReportStatisticsDTO reportStatisticsDTO) {
837 return productionEquipmentMapper.getMaintainCompleteRateDetails(reportStatisticsDTO);
838 }
831 @Override 839 @Override
832 public List<Map> getMaintainCompleteRateDetails(ReportStatisticsDTO reportStatisticsDTO) { 840 public List<Map> getMaintainCompleteRateDetails(ReportStatisticsDTO reportStatisticsDTO) {
833 List<Map> list = new ArrayList<>(); 841 List<Map> list = new ArrayList<>();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!