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 * @author ruoyi
*/ */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@EnableAsync //@EnableAsync
@EnableScheduling @EnableScheduling
public class RuoYiApplication public class RuoYiApplication
{ {

@ -8,9 +8,7 @@ import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.kaohe.domain.*; import com.ruoyi.kaohe.domain.*;
import com.ruoyi.kaohe.service.IKhPcEmpService; import com.ruoyi.kaohe.service.*;
import com.ruoyi.kaohe.service.IKhVoteEmpService;
import com.ruoyi.kaohe.service.IKhVoteService;
import com.ruoyi.kaohe.service.impl.KhVoteServiceImpl; import com.ruoyi.kaohe.service.impl.KhVoteServiceImpl;
import com.ruoyi.kaohe.util.PinYinUtil; import com.ruoyi.kaohe.util.PinYinUtil;
import org.springframework.security.access.prepost.PreAuthorize; 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.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.kaohe.service.IKhPingceService;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
@ -42,6 +39,8 @@ public class KhPingceController extends BaseController {
private IKhVoteService khVoteService; private IKhVoteService khVoteService;
@Autowired @Autowired
private IKhVoteEmpService khVoteEmpService; private IKhVoteEmpService khVoteEmpService;
@Autowired
private IKhVoteRecardService khVoteRecardService;
/** /**
* *
@ -156,7 +155,7 @@ public class KhPingceController extends BaseController {
* idpcBkhdxsaddOrDelbkhdxType * idpcBkhdxsaddOrDelbkhdxType
*/ */
// @PreAuthorize("@ss.hasPermi('kaohe:pingce:modifyBkhdx')") // @PreAuthorize("@ss.hasPermi('kaohe:pingce:modifyBkhdx')")
@Log(title = "考核评测", businessType = BusinessType.UPDATE) @Log(title = "任务添加/删除被考核对象", businessType = BusinessType.UPDATE)
@PutMapping("/modifyBkhdx") @PutMapping("/modifyBkhdx")
@Transactional @Transactional
public AjaxResult modifyBkhdx(@RequestBody ModifyBkhdxParam bkhdxParam) { public AjaxResult modifyBkhdx(@RequestBody ModifyBkhdxParam bkhdxParam) {
@ -204,10 +203,17 @@ public class KhPingceController extends BaseController {
} }
} else { } else {
//删除关联 //删除关联
List<Long> ids = new ArrayList<>();
KhPcEmp query = new KhPcEmp(); KhPcEmp query = new KhPcEmp();
query.setPcId(id); query.setPcId(id);
List<KhPcEmp> temItems = pcEmpService.selectKhPcEmpList(query); List<KhPcEmp> pcEmpsItems = pcEmpService.selectKhPcEmpList(query);
List<Long> ids = temItems.stream().map(KhPcEmp::getId).collect(Collectors.toList()); for (Bkhdx pcEmp : pcEmps) {
for (KhPcEmp pcEmpsItem : pcEmpsItems) {
if (pcEmpsItem.getBkhdxId().equals(pcEmp.getBkhdxId())) {
ids.add(pcEmpsItem.getId());
}
}
}
if (ids != null && ids.size() > 0) { if (ids != null && ids.size() > 0) {
pcEmpService.deleteKhPcEmpByIds(ids.toArray(new Long[ids.size()])); pcEmpService.deleteKhPcEmpByIds(ids.toArray(new Long[ids.size()]));
} }
@ -237,18 +243,18 @@ public class KhPingceController extends BaseController {
/** /**
* idsnull voteemp voteemp * idsnull voteemp voteemp
* vote_recard * vote_recard
* ids id-----votevoteemp * ids id-----votevoteemp
*/ */
// @PreAuthorize("@ss.hasPermi('kaohe:pingce:remove')") // @PreAuthorize("@ss.hasPermi('kaohe:pingce:remove')")
@Log(title = "考核评测", businessType = BusinessType.DELETE) @Log(title = "任务清除打分数据", businessType = BusinessType.DELETE)
@DeleteMapping("/clean") @DeleteMapping("/clean")
@Transactional @Transactional
public AjaxResult removeTest(@RequestParam Long[] ids) { public AjaxResult removeTest(@RequestParam Long[] ids) {
if (ids != null && ids.length > 0) { //按任务id-----修改所有关联的vote的voteemp数据为原始状态 if (ids != null && ids.length > 0) { //按任务id-----修改所有关联的vote的voteemp数据为原始状态
for (Long jxzId : ids) { for (Long cleanId : ids) {
KhVote vote = new KhVote(); KhVote vote = new KhVote();
vote.setPingceId(jxzId); vote.setPingceId(cleanId);
List<KhVote> votes = khVoteService.selectKhVoteList(vote); List<KhVote> votes = khVoteService.selectKhVoteList(vote);
if (votes != null && votes.size() > 0) { if (votes != null && votes.size() > 0) {
List<Long> vIds = votes.stream().map(KhVote::getId).collect(Collectors.toList()); 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 khPingce = new KhPingce();
khPingce.setState("2"); khPingce.setState("2");
@ -289,7 +304,7 @@ public class KhPingceController extends BaseController {
KhPingce jxz = new KhPingce(); KhPingce jxz = new KhPingce();
jxz.setState("1"); jxz.setState("1");
List<KhPingce> jxzPingces = khPingceService.selectKhPingceList(jxz); 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()); List<Long> jxzIds = jxzPingces.stream().map(KhPingce::getId).collect(Collectors.toList());
for (Long jxzId : jxzIds) { for (Long jxzId : jxzIds) {
KhVote vote = new KhVote(); 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}") @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) public AjaxResult remove(@PathVariable Long[] ids)
{ {
//修改,当考核任务再用这个模板时 不允许修改 //当有考核任务引用这个模板时 不允许修改
for(Long id:ids){ for(Long id:ids){
KhPingce pingce = new KhPingce(); KhPingce pingce = new KhPingce();
pingce.setTemplateId(id); pingce.setTemplateId(id);
pingce.setState("0"); List<KhPingce> khPingces = pingceService.selectKhPingceList(pingce);
List<KhPingce> khPingces = pingceService.selectKhUsedPingceList(pingce);
if(khPingces!=null&&khPingces.size()>0){ if(khPingces!=null&&khPingces.size()>0){
return AjaxResult.error("有考核任务已使用模板,不能删除"); 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 {
} }
} }
}*/ }
/** /**
* *

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

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

Loading…
Cancel
Save