Merge remote-tracking branch 'origin/main'

main
wanglei 1 month ago
commit f5dcab9caf

@ -3,6 +3,7 @@ package com.ruoyi;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
/** /**
@ -11,6 +12,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
* @author ruoyi * @author ruoyi
*/ */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@EnableAsync
@EnableScheduling @EnableScheduling
public class RuoYiApplication public class RuoYiApplication
{ {

@ -52,7 +52,8 @@ public class ResourcesConfig implements WebMvcConfigurer
registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**"); registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**");
registry.addInterceptor(licenseInterceptor) registry.addInterceptor(licenseInterceptor)
.addPathPatterns("/**") .addPathPatterns("/**")
.excludePathPatterns("/login", "/license/**"); .excludePathPatterns("/login", "/license/**","/kaohe/vote_emp/voteSubmit");
} }
/** /**

@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.kaohe.domain.*; import com.ruoyi.kaohe.domain.*;
import com.ruoyi.kaohe.service.IKhPingceService;
import com.ruoyi.kaohe.service.IKhTemItemService; import com.ruoyi.kaohe.service.IKhTemItemService;
import com.ruoyi.kaohe.service.IKhVoteService; import com.ruoyi.kaohe.service.IKhVoteService;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@ -38,6 +39,8 @@ public class KhTemplateController extends BaseController
private IKhTemItemService temItemService; private IKhTemItemService temItemService;
@Autowired @Autowired
private IKhVoteService voteService; private IKhVoteService voteService;
@Autowired
private IKhPingceService pingceService;
/** /**
* *
@ -162,6 +165,14 @@ public class KhTemplateController extends BaseController
@Transactional @Transactional
public AjaxResult edit(@RequestBody KhTemplate khTemplate) public AjaxResult edit(@RequestBody KhTemplate khTemplate)
{ {
//修改,当考核任务再用这个模板时 不允许修改
KhPingce pingce = new KhPingce();
pingce.setTemplateId(khTemplate.getId());
pingce.setState("0");
List<KhPingce> khPingces = pingceService.selectKhUsedPingceList(pingce);
if(khPingces!=null&&khPingces.size()>0){
return AjaxResult.error("有考核任务已使用模板,不能修改");
}
khTemplateService.updateKhTemplate(khTemplate); khTemplateService.updateKhTemplate(khTemplate);
List<KhItems> items = khTemplate.getItems(); List<KhItems> items = khTemplate.getItems();
if(items !=null&& items.size()>0){ if(items !=null&& items.size()>0){
@ -178,6 +189,8 @@ public class KhTemplateController extends BaseController
temItem.setTemId(khTemplate.getId()); temItem.setTemId(khTemplate.getId());
temItem.setItemName(item.getItemName()); temItem.setItemName(item.getItemName());
temItem.setKhitemId(item.getId()); temItem.setKhitemId(item.getId());
temItem.setType(item.getType());
temItem.setTypeId(item.getTypeId());
temItemService.insertKhTemItem(temItem); temItemService.insertKhTemItem(temItem);
} }
} }
@ -192,6 +205,16 @@ public class KhTemplateController extends BaseController
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) public AjaxResult remove(@PathVariable Long[] ids)
{ {
//修改,当考核任务再用这个模板时 不允许修改
for(Long id:ids){
KhPingce pingce = new KhPingce();
pingce.setTemplateId(id);
pingce.setState("0");
List<KhPingce> khPingces = pingceService.selectKhUsedPingceList(pingce);
if(khPingces!=null&&khPingces.size()>0){
return AjaxResult.error("有考核任务已使用模板,不能删除");
}
}
return toAjax(khTemplateService.deleteKhTemplateByIds(ids)); return toAjax(khTemplateService.deleteKhTemplateByIds(ids));
} }
} }

@ -46,7 +46,7 @@ public class KhVoteController extends BaseController {
@Autowired @Autowired
private IKhTemItemService khTemItemService; private IKhTemItemService khTemItemService;
@Scheduled(cron = "0 * * * * ?") // 每分钟的第0秒执行一次 监测时间修改评分状态 /*@Scheduled(cron = "0 * * * * ?") // 每分钟的第0秒执行一次 监测时间修改评分状态
public void performTask() { public void performTask() {
System.out.println("进入定时任务-------------------------------------------------------------"); System.out.println("进入定时任务-------------------------------------------------------------");
//获取所有未完成的评分任务 //获取所有未完成的评分任务
@ -97,7 +97,7 @@ public class KhVoteController extends BaseController {
} }
} }
} }*/
/** /**
* *

@ -23,7 +23,7 @@ public class KhVoteRecardParam extends BaseEntity
/** 评测id */ /** 评测id */
@Excel(name = "评测id") @Excel(name = "评测id")
private Long pcId; private Long pingceId;
/** 考核类型id */ /** 考核类型id */
@Excel(name = "考核类型id") @Excel(name = "考核类型id")
@ -76,12 +76,12 @@ public class KhVoteRecardParam extends BaseEntity
this.khitemTypeid = khitemTypeid; this.khitemTypeid = khitemTypeid;
} }
public Long getPcId() { public Long getPingceId() {
return pcId; return pingceId;
} }
public void setPcId(Long pcId) { public void setPingceId(Long pingceId) {
this.pcId = pcId; this.pingceId = pingceId;
} }
public Long getKhitemId() { public Long getKhitemId() {

@ -58,4 +58,6 @@ public interface KhPingceMapper
* @return * @return
*/ */
public int deleteKhPingceByIds(Long[] ids); public int deleteKhPingceByIds(Long[] ids);
List<KhPingce> selectKhUsedPingceList(KhPingce pingce);
} }

@ -60,4 +60,6 @@ public interface IKhPingceService
public int deleteKhPingceById(Long id); public int deleteKhPingceById(Long id);
int deleteKhPingceByIds2(Long[] toArray); int deleteKhPingceByIds2(Long[] toArray);
List<KhPingce> selectKhUsedPingceList(KhPingce pingce);
} }

@ -60,6 +60,11 @@ public class KhPingceServiceImpl implements IKhPingceService
return khPingceMapper.selectKhPingceList(khPingce); return khPingceMapper.selectKhPingceList(khPingce);
} }
@Override
public List<KhPingce> selectKhUsedPingceList(KhPingce pingce) {
return khPingceMapper.selectKhUsedPingceList(pingce);
}
/** /**
* *
* *

@ -14,6 +14,7 @@ import com.ruoyi.kaohe.domain.KhVoteRecardParam;
import com.ruoyi.kaohe.mapper.KhVoteItemsMapper; import com.ruoyi.kaohe.mapper.KhVoteItemsMapper;
import com.ruoyi.kaohe.mapper.KhVoteRecardMapper; import com.ruoyi.kaohe.mapper.KhVoteRecardMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.kaohe.mapper.KhVoteEmpMapper; import com.ruoyi.kaohe.mapper.KhVoteEmpMapper;
import com.ruoyi.kaohe.domain.KhVoteEmp; import com.ruoyi.kaohe.domain.KhVoteEmp;
@ -113,13 +114,25 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
@Override @Override
@Transactional @Transactional
@Async("threadPoolTaskExecutor")
public AjaxResult voteSubmit(KhVoteRecardParam param) { public AjaxResult voteSubmit(KhVoteRecardParam param) {
System.out.println("------------------------开始异步批量处理用户数据,线程:" + Thread.currentThread().getName());
Map<String, String> xuanxiangDetails = new LinkedHashMap<>(); Map<String, String> xuanxiangDetails = new LinkedHashMap<>();
Map<String, BigDecimal> pingFenDetails = new LinkedHashMap<>(); Map<String, BigDecimal> pingFenDetails = new LinkedHashMap<>();
BigDecimal num = new BigDecimal("1");//投票人数+1 BigDecimal num = new BigDecimal("1");//投票人数+1
List<KhVoteEmp> voteEmpList = param.getVoteEmpList(); List<KhVoteEmp> voteEmpList = param.getVoteEmpList();
Date nowDate = DateUtils.getNowDate(); Date nowDate = DateUtils.getNowDate();
Long typeid = param.getKhitemTypeid(); Long typeid = param.getKhitemTypeid();
//存储投票记录
KhVoteRecard recard = new KhVoteRecard();
recard.setRemark(JSON.toJSONString(voteEmpList));
recard.setPcId(param.getPingceId());
recard.setVoteId(param.getVoteId());
recard.setUserId(param.getUserId());
recard.setUserName(param.getUserName());
// recard.setUid(param.getUid());
//选项评分 //选项评分
if (typeid.equals(1L)) { if (typeid.equals(1L)) {
List<KhVoteItems> voteItems = khVoteItemsMapper.selectKhVoteItemsList(null);//从数据库获取分值 List<KhVoteItems> voteItems = khVoteItemsMapper.selectKhVoteItemsList(null);//从数据库获取分值
@ -198,14 +211,16 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
} else { } else {
// 更新失败,版本冲突,增加重试计数 // 更新失败,版本冲突,增加重试计数
retryCount++; retryCount++;
System.out.println("-----------版本冲突," + voteEmp.getId() + "第" + retryCount + "次重试"); if (retryCount > 3) {
// if (retryCount < MAX_RETRY_COUNT) { throw new RuntimeException("重试次数过多被中断-------------");
}
System.out.println("-----------版本冲突," + voteEmp.getBkhdxName() + "第" + retryCount + "次重试");
// 等待一段时间后重试,避免立即重试导致的持续冲突 // 等待一段时间后重试,避免立即重试导致的持续冲突
try { try {
Thread.sleep(100* retryCount); // 重试间隔递增 Thread.sleep(500 * retryCount); // 重试间隔递增
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
throw new RuntimeException("重试过程中断-------------", e); throw new RuntimeException("重试过程异常中断-------------", e);
} }
// } // }
} }
@ -231,14 +246,16 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
} else { } else {
// 更新失败,版本冲突,增加重试计数 // 更新失败,版本冲突,增加重试计数
retryCount++; retryCount++;
System.out.println("-----------版本冲突," + voteEmp.getId() + "第" + retryCount + "次重试"); if (retryCount > 3) {
// if (retryCount < MAX_RETRY_COUNT) { throw new RuntimeException("重试次数过多被中断-------------");
}
System.out.println("-----------版本冲突," + voteEmp.getBkhdxName() + "第" + retryCount + "次重试");
// 等待一段时间后重试,避免立即重试导致的持续冲突 // 等待一段时间后重试,避免立即重试导致的持续冲突
try { try {
Thread.sleep(100* retryCount); // 重试间隔递增 Thread.sleep(500 * retryCount); // 重试间隔递增
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
throw new RuntimeException("重试过程中断-------------", e); throw new RuntimeException("重试过程异常中断-------------", e);
} }
} }
} }
@ -263,14 +280,16 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
} else { } else {
// 更新失败,版本冲突,增加重试计数 // 更新失败,版本冲突,增加重试计数
retryCount++; retryCount++;
System.out.println("-----------版本冲突," + voteEmp.getId() + "第" + retryCount + "次重试"); if (retryCount > 3) {
// if (retryCount < MAX_RETRY_COUNT) { throw new RuntimeException("重试次数过多被中断-------------");
}
System.out.println("-----------版本冲突," + voteEmp.getBkhdxName() + "第" + retryCount + "次重试");
// 等待一段时间后重试,避免立即重试导致的持续冲突 // 等待一段时间后重试,避免立即重试导致的持续冲突
try { try {
Thread.sleep(100* retryCount); // 重试间隔递增 Thread.sleep(500 * retryCount); // 重试间隔递增
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
throw new RuntimeException("重试过程中断-------------", e); throw new RuntimeException("重试过程异常中断-------------", e);
} }
} }
} }
@ -278,11 +297,6 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
} }
//存储投票记录 //存储投票记录
KhVoteRecard recard = new KhVoteRecard();
recard.setVoteId(param.getVoteId());
recard.setUserId(param.getUserId());
recard.setUserName(param.getUserName());
recard.setUid(param.getUid());
recard.setVoteTime(nowDate); recard.setVoteTime(nowDate);
if (typeid.equals(1L)) {//选项评分 if (typeid.equals(1L)) {//选项评分
recard.setVoteDetails(JSON.toJSONString(xuanxiangDetails)); recard.setVoteDetails(JSON.toJSONString(xuanxiangDetails));
@ -297,7 +311,6 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
.collect(Collectors.toList()); .collect(Collectors.toList());
recard.setVoteDetails(JSON.toJSONString(details));*/ recard.setVoteDetails(JSON.toJSONString(details));*/
} }
recard.setRemark(JSON.toJSONString(voteEmpList));
khVoteRecardMapper.insertKhVoteRecard(recard); khVoteRecardMapper.insertKhVoteRecard(recard);
return AjaxResult.success(); return AjaxResult.success();
} }

@ -53,6 +53,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY id DESC ORDER BY id DESC
</select> </select>
<select id="selectKhUsedPingceList" parameterType="KhPingce" resultMap="KhPingceResult">
select id, pc_title from kh_pingce
<where>
<if test="templateId != null "> and template_id = #{templateId}</if>
<if test="state != null and state != ''"> and state &lt;&gt; #{state}</if>
</where>
ORDER BY id DESC
</select>
<select id="getBkhdxs" resultMap="BkhdxsResult"> <select id="getBkhdxs" resultMap="BkhdxsResult">
select pe.bkhdx_id,pe.bkhdx_name,pe.dept_id,pe.dept_name,emp.word_id,emp.`position` from kh_pc_emp pe left join kh_employee emp select pe.bkhdx_id,pe.bkhdx_name,pe.dept_id,pe.dept_name,emp.word_id,emp.`position` from kh_pc_emp pe left join kh_employee emp
on pe.bkhdx_id = emp.id on pe.bkhdx_id = emp.id

Loading…
Cancel
Save