Merge remote-tracking branch 'origin/main'

main
wanglei 1 month ago
commit 3b3f3ee64d

@ -237,21 +237,21 @@ public class KhPingceController extends BaseController {
/**
* idsnull voteemp voteemp
* ids id-----votevoteemp
* vote_recard
* ids id-----votevoteemp
*/
// @PreAuthorize("@ss.hasPermi('kaohe:pingce:remove')")
@Log(title = "考核评测", businessType = BusinessType.DELETE)
@DeleteMapping("/clean")
@Transactional
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) {
KhVote vote = new KhVote();
vote.setPingceId(jxzId);
List<KhVote> votes = khVoteService.selectKhVoteList(vote);
if (votes != null && votes.size() > 0) {
List<Long> vIds = votes.stream().map(KhVote::getId).collect(Collectors.toList());
if (vIds != null && vIds.size() > 0) {
//修改voteemp
for (Long vId : vIds) {
KhVoteEmp vemp = new KhVoteEmp();
@ -276,7 +276,7 @@ public class KhPingceController extends BaseController {
}
}
}
}else{//null认为清理所有 (已完成删除全部数据,进行中数据清除评分数据)
} else {//null认为清理所有 (已完成删除全部数据,进行中数据清除评分数据)
//已完成的数据直接清除任务及所有关联数据————完全删除已完成任务
KhPingce khPingce = new KhPingce();
khPingce.setState("2");
@ -289,13 +289,14 @@ public class KhPingceController extends BaseController {
KhPingce jxz = new KhPingce();
jxz.setState("1");
List<KhPingce> jxzPingces = khPingceService.selectKhPingceList(jxz);
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();
vote.setPingceId(jxzId);
List<KhVote> votes = khVoteService.selectKhVoteList(vote);
if (votes != null && votes.size() > 0) {
List<Long> vIds = votes.stream().map(KhVote::getId).collect(Collectors.toList());
if (vIds != null && vIds.size() > 0) {
//修改voteemp
for (Long vId : vIds) {
KhVoteEmp vemp = new KhVoteEmp();
@ -321,6 +322,7 @@ public class KhPingceController extends BaseController {
}
}
}
}
return toAjax(1);
}

@ -48,6 +48,18 @@ public class KhVoteEmpController extends BaseController
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('kaohe:vote_emp:list')")
@GetMapping("/getVoteEmps")
public TableDataInfo getVoteEmps(KhVoteEmp khVoteEmp)
{
startPage();
List<KhVoteEmp> list = khVoteEmpService.selectVoteEmpsByVoteId(khVoteEmp);
return getDataTable(list);
}
/**
*
*/

@ -79,9 +79,21 @@ public class KhVoteEmp extends BaseEntity
@Excel(name = "最终分数")
private BigDecimal endScore;
/** 乐观锁版本号 */
@Excel(name = "乐观锁版本号")
private Long version;
//仅做参数 传递本次评分分数
private BigDecimal score;
public Long getVersion() {
return version;
}
public void setVersion(Long version) {
this.version = version;
}
public BigDecimal getScore() {
return score;
}
@ -262,6 +274,7 @@ public class KhVoteEmp extends BaseEntity
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.append("version", getVersion())
.toString();
}
}

@ -21,9 +21,13 @@ public class KhVoteRecard extends BaseEntity
private Long id;
/** 评测id */
@Excel(name = "评测id")
// @Excel(name = "评测id")
private Long pcId;
/** 评测id */
@Excel(name = "考核任务名称")
private String pcName;
/** 考核项id */
@Excel(name = "考核项id")
private Long khitemId;
@ -32,6 +36,11 @@ public class KhVoteRecard extends BaseEntity
@Excel(name = "投票活动id")
private Long voteId;
/** 评测id */
@Excel(name = "评分主题")
private String votTitle;
/** 用户id */
@Excel(name = "用户id")
private Long userId;
@ -41,11 +50,11 @@ public class KhVoteRecard extends BaseEntity
private String userName;
/** 投票人uid */
@Excel(name = "投票人uid")
// @Excel(name = "投票人uid")
private String uid;
/** 投票人 */
@Excel(name = "投票人")
// @Excel(name = "投票人")
private String tprName;
/** 评分详情 */
@ -58,9 +67,25 @@ public class KhVoteRecard extends BaseEntity
private Date voteTime;
/** IP */
@Excel(name = "IP")
// @Excel(name = "IP")
private String ipAddress;
public String getPcName() {
return pcName;
}
public void setPcName(String pcName) {
this.pcName = pcName;
}
public String getVoteTitle() {
return votTitle;
}
public void setVoteTitle(String voteTitle) {
this.votTitle = voteTitle;
}
public void setId(Long id)
{
this.id = id;

@ -58,4 +58,6 @@ public interface KhVoteEmpMapper
* @return
*/
public int deleteKhVoteEmpByIds(Long[] ids);
List<KhVoteEmp> selectVoteEmpsByVoteId(KhVoteEmp khVoteEmp);
}

@ -63,4 +63,6 @@ public interface IKhVoteEmpService
public int deleteKhVoteEmpById(Long id);
AjaxResult voteSubmit(KhVoteRecardParam param);
List<KhVoteEmp> selectVoteEmpsByVoteId(KhVoteEmp khVoteEmp);
}

@ -20,6 +20,8 @@ import com.ruoyi.kaohe.domain.KhVoteEmp;
import com.ruoyi.kaohe.service.IKhVoteEmpService;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
/**
* Service
*
@ -57,6 +59,11 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
return khVoteEmpMapper.selectKhVoteEmpList(khVoteEmp);
}
@Override
public List<KhVoteEmp> selectVoteEmpsByVoteId(KhVoteEmp khVoteEmp) {
return khVoteEmpMapper.selectVoteEmpsByVoteId(khVoteEmp);
}
/**
*
*
@ -94,6 +101,7 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
/**
*
*
*
* @param id
* @return
@ -106,46 +114,64 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
@Override
@Transactional
public AjaxResult voteSubmit(KhVoteRecardParam param) {
Map<String, BigDecimal> xuanxiangDetails = new HashMap<>();
Map<String, String> xuanxiangDetails = new LinkedHashMap<>();
Map<String, BigDecimal> pingFenDetails = new LinkedHashMap<>();
BigDecimal num = new BigDecimal("1");//投票人数+1
List<KhVoteEmp> voteEmpList = param.getVoteEmpList();
Date nowDate = DateUtils.getNowDate();
Long typeid = param.getKhitemTypeid();
//选项评分
if (typeid.equals(1L)) {
List<KhVoteItems> voteItems = khVoteItemsMapper.selectKhVoteItemsList(null);//从数据库获取分值
BigDecimal a = new BigDecimal("100");
BigDecimal b = new BigDecimal("80");
BigDecimal c = new BigDecimal("60");
BigDecimal d = new BigDecimal("40");
if(voteItems!=null&&voteItems.size()>0){
String aName = "优秀";
String bName = "合格";
String cName = "基本合格";
String dName = "不合格";
if (voteItems != null && voteItems.size() > 0) {
for (KhVoteItems voteItem : voteItems) {
if (voteItem.getId() == 1) {
a = voteItem.getScore();
aName = voteItem.getVitemName();
} else if (voteItem.getId() == 2) {
b = voteItem.getScore();
bName = voteItem.getVitemName();
} else if (voteItem.getId() == 3) {
c = voteItem.getScore();
cName = voteItem.getVitemName();
} else {
d = voteItem.getScore();
dName = voteItem.getVitemName();
}
}
}
for (KhVoteEmp voteEmp : voteEmpList) {
// 最大重试次数
// final int MAX_RETRY_COUNT = 3;
int retryCount = 0;
while (true) {
voteEmp.setUpdateTime(nowDate);
//根据id查询数据得到之前的值
//根据id查询数据得到原值及版本号
KhVoteEmp oldvoteEmp = khVoteEmpMapper.selectKhVoteEmpById(voteEmp.getId());
if (typeid.equals(1L)) {//选项评分
//存储投票详情到map
if (voteEmp.getOptionA().compareTo(BigDecimal.ZERO) == 1) {
xuanxiangDetails.put(voteEmp.getBkhdxName(), voteEmp.getOptionA());
// xuanxiangDetails.put(voteEmp.getBkhdxId().toString(), voteEmp.getBkhdxName()+":优秀");
xuanxiangDetails.put(voteEmp.getBkhdxName(), aName);
}
if (voteEmp.getOptionB().compareTo(BigDecimal.ZERO) == 1) {
xuanxiangDetails.put(voteEmp.getBkhdxName(), voteEmp.getOptionB());
//xuanxiangDetails.put(voteEmp.getBkhdxId().toString(), voteEmp.getBkhdxName()+":合格");
xuanxiangDetails.put(voteEmp.getBkhdxName(), bName);
}
if (voteEmp.getOptionC().compareTo(BigDecimal.ZERO) == 1) {
xuanxiangDetails.put(voteEmp.getBkhdxName(), voteEmp.getOptionC());
//xuanxiangDetails.put(voteEmp.getBkhdxId().toString(), voteEmp.getBkhdxName()+":基本合格");
xuanxiangDetails.put(voteEmp.getBkhdxName(), cName);
}
if (voteEmp.getOptionD().compareTo(BigDecimal.ZERO) == 1) {
xuanxiangDetails.put(voteEmp.getBkhdxName(), voteEmp.getOptionD());
//xuanxiangDetails.put(voteEmp.getBkhdxId().toString(), voteEmp.getBkhdxName()+":不合格");
xuanxiangDetails.put(voteEmp.getBkhdxName(), dName);
}
//修改投票情况
BigDecimal optionA = voteEmp.getOptionA().add(oldvoteEmp.getOptionA());
@ -154,7 +180,7 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
BigDecimal optionD = voteEmp.getOptionD().add(oldvoteEmp.getOptionD());
voteEmp.setVoteNum(oldvoteEmp.getVoteNum().add(num));
BigDecimal avgScore = (optionA.multiply(a).add(optionB.multiply(b).add(optionC.multiply(c).add(optionD.multiply(d)))
)).divide(voteEmp.getVoteNum(),4, RoundingMode.HALF_UP);
)).divide(voteEmp.getVoteNum(), 4, RoundingMode.HALF_UP);
voteEmp.setAvgScore(avgScore);//投票后计算平均分
voteEmp.setOptionA(optionA);
voteEmp.setOptionB(optionB);
@ -162,26 +188,95 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
voteEmp.setOptionD(optionD);
if (oldvoteEmp.getPercentage() != null) { //计算最后得分
voteEmp.setEndScore(avgScore.multiply(oldvoteEmp.getPercentage()));
}else{
} else {
voteEmp.setEndScore(avgScore);
}
voteEmp.setVersion(oldvoteEmp.getVersion());
int result = khVoteEmpMapper.updateKhVoteEmp(voteEmp);
if (result > 0) {
break;
} else {
// 更新失败,版本冲突,增加重试计数
retryCount++;
System.out.println("-----------版本冲突," + voteEmp.getId() + "第" + retryCount + "次重试");
// if (retryCount < MAX_RETRY_COUNT) {
// 等待一段时间后重试,避免立即重试导致的持续冲突
try {
Thread.sleep(100* 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) {
voteEmp.setUpdateTime(nowDate);
//根据id查询数据得到之前的值
KhVoteEmp oldvoteEmp = khVoteEmpMapper.selectKhVoteEmpById(voteEmp.getId());
BigDecimal sumScore = voteEmp.getScore().add(oldvoteEmp.getVoteScore());
voteEmp.setVoteScore(sumScore);
//修改投票人数 平均分*占比=最后得分
voteEmp.setVoteNum(oldvoteEmp.getVoteNum().add(num));
voteEmp.setAvgScore(sumScore.divide(voteEmp.getVoteNum(),4, RoundingMode.HALF_UP));
voteEmp.setAvgScore(sumScore.divide(voteEmp.getVoteNum(), 4, RoundingMode.HALF_UP));
voteEmp.setEndScore(voteEmp.getAvgScore().multiply(oldvoteEmp.getPercentage()));
voteEmp.setVersion(oldvoteEmp.getVersion());
int result = khVoteEmpMapper.updateKhVoteEmp(voteEmp);
if (result > 0) {
break;
} else {
// 更新失败,版本冲突,增加重试计数
retryCount++;
System.out.println("-----------版本冲突," + voteEmp.getId() + "第" + retryCount + "次重试");
// if (retryCount < MAX_RETRY_COUNT) {
// 等待一段时间后重试,避免立即重试导致的持续冲突
try {
Thread.sleep(100* retryCount); // 重试间隔递增
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("重试过程被中断-------------", e);
}
}
}
}
} else {//单独评分 不占比 以平均分为最后得分
for (KhVoteEmp voteEmp : voteEmpList) {
int retryCount = 0;
while (true) {
voteEmp.setUpdateTime(nowDate);
//根据id查询数据得到之前的值
KhVoteEmp oldvoteEmp = khVoteEmpMapper.selectKhVoteEmpById(voteEmp.getId());
BigDecimal sumScore = voteEmp.getScore().add(oldvoteEmp.getVoteScore());
voteEmp.setVoteNum(oldvoteEmp.getVoteNum()
.add(num));
voteEmp.setVoteScore(sumScore);
voteEmp.setAvgScore(sumScore.divide(voteEmp.getVoteNum(),4, RoundingMode.HALF_UP));
voteEmp.setAvgScore(sumScore.divide(voteEmp.getVoteNum(), 4, RoundingMode.HALF_UP));
voteEmp.setEndScore(voteEmp.getAvgScore());
voteEmp.setVersion(oldvoteEmp.getVersion());
int result = khVoteEmpMapper.updateKhVoteEmp(voteEmp);
if (result > 0) {
break;
} else {
// 更新失败,版本冲突,增加重试计数
retryCount++;
System.out.println("-----------版本冲突," + voteEmp.getId() + "第" + retryCount + "次重试");
// if (retryCount < MAX_RETRY_COUNT) {
// 等待一段时间后重试,避免立即重试导致的持续冲突
try {
Thread.sleep(100* retryCount); // 重试间隔递增
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("重试过程被中断-------------", e);
}
}
}
khVoteEmpMapper.updateKhVoteEmp(voteEmp);
}
}
//存储投票记录
KhVoteRecard recard = new KhVoteRecard();
recard.setVoteId(param.getVoteId());
@ -192,11 +287,17 @@ public class KhVoteEmpServiceImpl implements IKhVoteEmpService {
if (typeid.equals(1L)) {//选项评分
recard.setVoteDetails(JSON.toJSONString(xuanxiangDetails));
} else {
List<String> details = voteEmpList.stream()
for (KhVoteEmp voteEmp : voteEmpList) {
//xuanxiangDetails.put(voteEmp.getBkhdxId().toString(), voteEmp.getBkhdxName()+":"+voteEmp.getScore());
pingFenDetails.put(voteEmp.getBkhdxName()/*+voteEmp.getBkhdxId()*/, voteEmp.getScore());
recard.setVoteDetails(JSON.toJSONString(pingFenDetails));
}
/*List<String> details = voteEmpList.stream()
.map(emp -> emp.getBkhdxName() + " : " + emp.getScore())
.collect(Collectors.toList());
recard.setVoteDetails(JSON.toJSONString(details));
recard.setVoteDetails(JSON.toJSONString(details));*/
}
recard.setRemark(JSON.toJSONString(voteEmpList));
khVoteRecardMapper.insertKhVoteRecard(recard);
return AjaxResult.success();
}

@ -26,10 +26,11 @@
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="version" column="version" />
</resultMap>
<sql id="selectKhVoteEmpVo">
select id, khitem_typeId, vote_id, vote_title, bkhdx_id, bkhdx_name, content, vote_num,option_a, option_b, option_c, option_d, vote_score, avg_score, percentage, end_score, create_by, create_time, update_by, update_time, remark from kh_vote_emp
select id, khitem_typeId, vote_id, vote_title, bkhdx_id, bkhdx_name, content, vote_num,option_a, option_b, option_c, option_d, vote_score, avg_score, percentage, end_score, create_by, create_time, update_by, update_time, remark, version from kh_vote_emp
</sql>
<select id="selectKhVoteEmpList" parameterType="KhVoteEmp" resultMap="KhVoteEmpResult">
@ -50,6 +51,14 @@
<if test="avgScore != null "> and avg_score = #{avgScore}</if>
<if test="percentage != null "> and percentage = #{percentage}</if>
<if test="endScore != null "> and end_score = #{endScore}</if>
<!--<if test="version != null "> and version = #{version}</if>-->
</where>
</select>
<!--投票页面查询考核及考核对象信息-->
<select id="selectVoteEmpsByVoteId" parameterType="KhVoteEmp" resultMap="KhVoteEmpResult">
select id, khitem_typeId, vote_id, bkhdx_id, bkhdx_name from kh_vote_emp
<where>
<if test="voteId != null "> and vote_id = #{voteId}</if>
</where>
</select>
@ -81,6 +90,7 @@
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<!--<if test="version != null">version,</if>-->
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="khitemTypeid != null">#{khitemTypeid},</if>
@ -103,6 +113,7 @@
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<!--<if test="version != null">#{version},</if>-->
</trim>
</insert>
@ -129,8 +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}
<!-- 其他需要更新的字段 -->
WHERE id = #{id} AND version = #{version}
</update>
<delete id="deleteKhVoteEmpById" parameterType="Long">

@ -56,11 +56,11 @@
</where>
</select>
<!--生成评测账号登录时筛选符合条件的vote展示评分 ————废弃———— -->
<select id="getListByPcIdAndItemIds" parameterType="KhVote" resultMap="KhVoteResult">
<!--<select id="getListByPcIdAndItemIds" parameterType="KhVote" resultMap="KhVoteResult">
select v.*,it.type_id from kh_vote v left join kh_items it on v.khitem_id =it.id
<where>
<if test="pingceId != null "> and pingce_id = #{pingceId}</if>
<!--状态值传1也就是展示所有状态不等于2非完成状态的数据-->
&lt;!&ndash;状态值传1也就是展示所有状态不等于2非完成状态的数据&ndash;&gt;
<if test="state != null and state != ''"> and state != #{state}</if>
<if test="itemIds != null"> and khitem_id in
<foreach item="itemId" collection="itemIds" open="(" separator="," close=")">
@ -68,12 +68,13 @@
</foreach>
</if>
</where>
</select>
</select>-->
<!-- 评测账号登录时筛选符合条件的vote展示评分 -->
<select id="getListByVoteIds" parameterType="KhVote" resultMap="KhVoteResult">
select v.*,it.type_id from kh_vote v left join kh_items it on v.khitem_id =it.id
<where>
<if test="pingceId != null "> and pingce_id = #{pingceId}</if>
<if test="pingceName != null and pingceName != ''"> and pingce_name like concat('%', #{pingceName}, '%')</if>
<if test="voteTitle != null and voteTitle != ''"> and vote_title like concat('%', #{voteTitle}, '%') </if>
<!--状态值传1也就是展示所有状态不等于2非完成状态的数据-->
<if test="state != null and state != ''"> and state != #{state}</if>
<if test="voteIds != null"> and v.id in

@ -6,9 +6,11 @@
<resultMap type="KhVoteRecard" id="KhVoteRecardResult">
<result property="id" column="id" />
<result property="pcId" column="pc_id" />
<result property="pcId" column="pingce_id" />
<result property="pcName" column="pingce_name" />
<result property="khitemId" column="khitem_id" />
<result property="voteId" column="vote_id" />
<result property="votTitle" column="vote_title" />
<result property="userId" column="user_id" />
<result property="userName" column="user_name" />
<result property="uid" column="uid" />
@ -28,18 +30,21 @@
</sql>
<select id="selectKhVoteRecardList" parameterType="KhVoteRecard" resultMap="KhVoteRecardResult">
<include refid="selectKhVoteRecardVo"/>
select r.id,v.pingce_id,r.vote_id,r.user_name,r.vote_details,r.vote_time,v.pingce_name,v.vote_title
from kh_vote_recard r join kh_vote v on r.vote_id=v.id
<where>
<if test="pcId != null "> and pc_id = #{pcId}</if>
<if test="khitemId != null "> and khitem_id = #{khitemId}</if>
<if test="voteId != null "> and vote_id = #{voteId}</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
<if test="uid != null "> and uid = #{uid}</if>
<if test="tprName != null and tprName != ''"> and tpr_name like concat('%', #{tprName}, '%')</if>
<if test="voteDetails != null and voteDetails != ''"> and vote_details = #{voteDetails}</if>
<if test="voteTime != null "> and vote_time = #{voteTime}</if>
<if test="ipAddress != null and ipAddress != ''"> and ip_address = #{ipAddress}</if>
<if test="pcId != null "> and v.pingce_id = #{pcId}</if>
<if test="pcName != null and pcName != '' "> and v.pingce_name like concat('%', #{pcName}, '%')</if>
<if test="khitemId != null "> and r.khitem_id = #{khitemId}</if>
<if test="voteId != null "> and r.vote_id = #{voteId}</if>
<if test="voteTitle != null and voteTitle != '' "> and v.vote_title like concat('%', #{voteTitle}, '%')</if>
<if test="userId != null "> and r.user_id = #{userId}</if>
<if test="userName != null and userName != ''"> and r.user_name like concat('%', #{userName}, '%')</if>
<if test="uid != null "> and r.uid = #{uid}</if>
<if test="tprName != null and tprName != ''"> and r.tpr_name like concat('%', #{tprName}, '%')</if>
<!-- <if test="voteDetails != null and voteDetails != ''"> and r.vote_details = #{voteDetails}</if>-->
<if test="voteTime != null "> and r.vote_time = #{voteTime}</if>
<if test="ipAddress != null and ipAddress != ''"> and r.ip_address = #{ipAddress}</if>
</where>
</select>

Loading…
Cancel
Save