Merge remote-tracking branch 'origin/main'

main
wanglei 1 month ago
commit 8fb70c5db3

@ -12,7 +12,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
* @author ruoyi
*/
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@EnableAsync
//@EnableAsync
@EnableScheduling
public class RuoYiApplication
{

@ -8,9 +8,7 @@ import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.kaohe.domain.*;
import com.ruoyi.kaohe.service.IKhPcEmpService;
import com.ruoyi.kaohe.service.IKhVoteEmpService;
import com.ruoyi.kaohe.service.IKhVoteService;
import com.ruoyi.kaohe.service.*;
import com.ruoyi.kaohe.service.impl.KhVoteServiceImpl;
import com.ruoyi.kaohe.util.PinYinUtil;
import org.springframework.security.access.prepost.PreAuthorize;
@ -21,7 +19,6 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.kaohe.service.IKhPingceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
@ -42,6 +39,8 @@ public class KhPingceController extends BaseController {
private IKhVoteService khVoteService;
@Autowired
private IKhVoteEmpService khVoteEmpService;
@Autowired
private IKhVoteRecardService khVoteRecardService;
/**
*
@ -156,7 +155,7 @@ public class KhPingceController extends BaseController {
* idpcBkhdxsaddOrDelbkhdxType
*/
// @PreAuthorize("@ss.hasPermi('kaohe:pingce:modifyBkhdx')")
@Log(title = "考核评测", businessType = BusinessType.UPDATE)
@Log(title = "任务添加/删除被考核对象", businessType = BusinessType.UPDATE)
@PutMapping("/modifyBkhdx")
@Transactional
public AjaxResult modifyBkhdx(@RequestBody ModifyBkhdxParam bkhdxParam) {
@ -204,10 +203,17 @@ public class KhPingceController extends BaseController {
}
} else {
//删除关联
List<Long> ids = new ArrayList<>();
KhPcEmp query = new KhPcEmp();
query.setPcId(id);
List<KhPcEmp> temItems = pcEmpService.selectKhPcEmpList(query);
List<Long> ids = temItems.stream().map(KhPcEmp::getId).collect(Collectors.toList());
List<KhPcEmp> pcEmpsItems = pcEmpService.selectKhPcEmpList(query);
for (Bkhdx pcEmp : pcEmps) {
for (KhPcEmp pcEmpsItem : pcEmpsItems) {
if (pcEmpsItem.getBkhdxId().equals(pcEmp.getBkhdxId())) {
ids.add(pcEmpsItem.getId());
}
}
}
if (ids != null && ids.size() > 0) {
pcEmpService.deleteKhPcEmpByIds(ids.toArray(new Long[ids.size()]));
}
@ -237,18 +243,18 @@ public class KhPingceController extends BaseController {
/**
* idsnull voteemp voteemp
* vote_recard
* vote_recard
* ids id-----votevoteemp
*/
// @PreAuthorize("@ss.hasPermi('kaohe:pingce:remove')")
@Log(title = "考核评测", businessType = BusinessType.DELETE)
@Log(title = "任务清除打分数据", businessType = BusinessType.DELETE)
@DeleteMapping("/clean")
@Transactional
public AjaxResult removeTest(@RequestParam Long[] ids) {
if (ids != null && ids.length > 0) { //按任务id-----修改所有关联的vote的voteemp数据为原始状态
for (Long jxzId : ids) {
for (Long cleanId : ids) {
KhVote vote = new KhVote();
vote.setPingceId(jxzId);
vote.setPingceId(cleanId);
List<KhVote> votes = khVoteService.selectKhVoteList(vote);
if (votes != null && votes.size() > 0) {
List<Long> vIds = votes.stream().map(KhVote::getId).collect(Collectors.toList());
@ -274,9 +280,18 @@ public class KhPingceController extends BaseController {
}
}
}
//清空投票记录表 根据pcId查询
KhVoteRecard vr = new KhVoteRecard();
vr.setPcId(cleanId);
List<KhVoteRecard> khVoteRecards = khVoteRecardService.selectKhVoteRecardList(vr);
if (khVoteRecards != null & khVoteRecards.size() > 0) {
List<Long> vrIds = khVoteRecards.stream().map(KhVoteRecard::getId).collect(Collectors.toList());
khVoteRecardService.deleteKhVoteRecardByIds(vrIds.toArray(new Long[vrIds.size()]));
}
}
}
} else {//null认为清理所有 (已完成删除全部数据,进行中数据清除评分数据)
return toAjax(1);
} /*else {//null认为清理所有 (已完成删除全部数据,进行中数据清除评分数据)
//已完成的数据直接清除任务及所有关联数据————完全删除已完成任务
KhPingce khPingce = new KhPingce();
khPingce.setState("2");
@ -289,7 +304,7 @@ public class KhPingceController extends BaseController {
KhPingce jxz = new KhPingce();
jxz.setState("1");
List<KhPingce> jxzPingces = khPingceService.selectKhPingceList(jxz);
if(jxzPingces!=null&&jxzPingces.size()>0){
if (jxzPingces != null && jxzPingces.size() > 0) {
List<Long> jxzIds = jxzPingces.stream().map(KhPingce::getId).collect(Collectors.toList());
for (Long jxzId : jxzIds) {
KhVote vote = new KhVote();
@ -319,11 +334,21 @@ public class KhPingceController extends BaseController {
}
}
}
//清空投票记录表 根据pcId查询
KhVoteRecard vr = new KhVoteRecard();
vr.setPcId(jxzId);
List<KhVoteRecard> khVoteRecards = khVoteRecardService.selectKhVoteRecardList(vr);
if (khVoteRecards != null & khVoteRecards.size() > 0) {
List<Long> vrIds = khVoteRecards.stream().map(KhVoteRecard::getId).collect(Collectors.toList());
khVoteRecardService.deleteKhVoteRecardByIds(vrIds.toArray(new Long[vrIds.size()]));
}
}
}
}
}
AjaxResult.success("按要求清理数据库成功")
}*/
return toAjax(1);
return AjaxResult.error("请选择需要清理的考核任务!");
}
}

@ -205,14 +205,13 @@ public class KhTemplateController extends BaseController
@DeleteMapping("/{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);
List<KhPingce> khPingces = pingceService.selectKhPingceList(pingce);
if(khPingces!=null&&khPingces.size()>0){
return AjaxResult.error("有考核任务已使用模板,不能删除");
return AjaxResult.error("有考核任务用模板,不能删除");
}
}
return toAjax(khTemplateService.deleteKhTemplateByIds(ids));

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

@ -114,7 +114,7 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
@Override
@Transactional
@Async("threadPoolTaskExecutor")
// @Async("threadPoolTaskExecutor")
public AjaxResult voteSubmit(KhVoteRecardParam param) {
System.out.println("------------------------开始异步批量处理用户数据,线程:" + Thread.currentThread().getName());
Map<String, String> xuanxiangDetails = new LinkedHashMap<>();
@ -165,7 +165,7 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
// 最大重试次数
// final int MAX_RETRY_COUNT = 3;
int retryCount = 0;
while (true) {
/* while (true) {*/
voteEmp.setUpdateTime(nowDate);
//根据id查询数据得到原值及版本号
KhVoteEmp oldvoteEmp = khVoteEmpMapper.selectKhVoteEmpById(voteEmp.getId());
@ -206,7 +206,7 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
}
voteEmp.setVersion(oldvoteEmp.getVersion());
int result = khVoteEmpMapper.updateKhVoteEmp(voteEmp);
if (result > 0) {
/*if (result > 0) {
break;
} else {
// 更新失败,版本冲突,增加重试计数
@ -217,19 +217,19 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
System.out.println("-----------版本冲突," + voteEmp.getBkhdxName() + "第" + retryCount + "次重试");
// 等待一段时间后重试,避免立即重试导致的持续冲突
try {
Thread.sleep(500 * retryCount); // 重试间隔递增
Thread.sleep(1000 * retryCount); // 重试间隔递增
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("重试过程异常中断-------------", e);
}
// }
}
}
}*/
}
} else if (typeid.equals(2L)) {//占比评分
for (KhVoteEmp voteEmp : voteEmpList) {
int retryCount = 0;
while (true) {
/* while (true) {*/
voteEmp.setUpdateTime(nowDate);
//根据id查询数据得到之前的值
KhVoteEmp oldvoteEmp = khVoteEmpMapper.selectKhVoteEmpById(voteEmp.getId());
@ -241,7 +241,7 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
voteEmp.setEndScore(voteEmp.getAvgScore().multiply(oldvoteEmp.getPercentage()));
voteEmp.setVersion(oldvoteEmp.getVersion());
int result = khVoteEmpMapper.updateKhVoteEmp(voteEmp);
if (result > 0) {
/*if (result > 0) {
break;
} else {
// 更新失败,版本冲突,增加重试计数
@ -252,18 +252,18 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
System.out.println("-----------版本冲突," + voteEmp.getBkhdxName() + "第" + retryCount + "次重试");
// 等待一段时间后重试,避免立即重试导致的持续冲突
try {
Thread.sleep(500 * retryCount); // 重试间隔递增
Thread.sleep(1000 * retryCount); // 重试间隔递增
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("重试过程异常中断-------------", e);
}
}
}
}*/
}
} else {//单独评分 不占比 以平均分为最后得分
for (KhVoteEmp voteEmp : voteEmpList) {
int retryCount = 0;
while (true) {
/* while (true) {*/
voteEmp.setUpdateTime(nowDate);
//根据id查询数据得到之前的值
KhVoteEmp oldvoteEmp = khVoteEmpMapper.selectKhVoteEmpById(voteEmp.getId());
@ -275,7 +275,7 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
voteEmp.setEndScore(voteEmp.getAvgScore());
voteEmp.setVersion(oldvoteEmp.getVersion());
int result = khVoteEmpMapper.updateKhVoteEmp(voteEmp);
if (result > 0) {
/*if (result > 0) {
break;
} else {
// 更新失败,版本冲突,增加重试计数
@ -286,13 +286,13 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
System.out.println("-----------版本冲突," + voteEmp.getBkhdxName() + "第" + retryCount + "次重试");
// 等待一段时间后重试,避免立即重试导致的持续冲突
try {
Thread.sleep(500 * retryCount); // 重试间隔递增
Thread.sleep(1000 * retryCount); // 重试间隔递增
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("重试过程异常中断-------------", e);
}
}
}
}*/
}
}

@ -140,10 +140,10 @@
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
version = version + 1
</trim>
<!-- 其他需要更新的字段 -->
WHERE id = #{id} AND version = #{version}
<!-- 其他需要更新的字段 /* version = version + 1 AND version = #{version}*/-->
WHERE id = #{id}
</update>
<delete id="deleteKhVoteEmpById" parameterType="Long">

Loading…
Cancel
Save