feat(examine): 更新考核任务模板
- 在 ExamineConfigMapper 和 ExamineDetailMapper 中添加了按任务 ID 删除记录的方法 - 更新了 ExamineTaskMapper 和 ExamineTemplateMapper 的查询语句,增加了模板类型和名称字段 - 修改了 TaskServiceImpl 中的 updateTask 方法,以支持更换考核模板时自动更新指标项dev_1.2.1
parent
d010449773
commit
c03486036f
|
@ -86,5 +86,7 @@ public interface ExamineConfigMapper {
|
||||||
|
|
||||||
List<ExamineConfig> list(ExamineConfig examineConfig);
|
List<ExamineConfig> list(ExamineConfig examineConfig);
|
||||||
|
|
||||||
|
void deleteByTaskId(Integer taskId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,5 +78,7 @@ public interface ExamineDetailMapper {
|
||||||
void deleteByExamineId(List<Integer> collect);
|
void deleteByExamineId(List<Integer> collect);
|
||||||
|
|
||||||
List<ExamineDetail> listByExamineId(List<Integer> idList);
|
List<ExamineDetail> listByExamineId(List<Integer> idList);
|
||||||
|
|
||||||
|
void deleteByTaskId(Integer taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ public interface ExamineDetailService {
|
||||||
|
|
||||||
|
|
||||||
void deleteByExamineId( List<Integer> collect);
|
void deleteByExamineId( List<Integer> collect);
|
||||||
|
void deleteByTaskId( Integer taskId);
|
||||||
|
|
||||||
List<ExamineDetail> listByExamineId(List<Integer> taskId);
|
List<ExamineDetail> listByExamineId(List<Integer> taskId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,6 +198,13 @@ public class ExamineDetailServiceImpl implements ExamineDetailService {
|
||||||
examineDetailMapper.deleteByExamineId(collect);
|
examineDetailMapper.deleteByExamineId(collect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteByTaskId(Integer taskId) {
|
||||||
|
examineDetailMapper.deleteByTaskId(taskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ExamineDetail> listByExamineId(List<Integer> idList) {
|
public List<ExamineDetail> listByExamineId(List<Integer> idList) {
|
||||||
return examineDetailMapper.listByExamineId(idList);
|
return examineDetailMapper.listByExamineId(idList);
|
||||||
|
|
|
@ -44,5 +44,7 @@ public class ExamineTask implements Serializable {
|
||||||
|
|
||||||
private Integer year;
|
private Integer year;
|
||||||
private Integer templateId;
|
private Integer templateId;
|
||||||
|
private String templateType;
|
||||||
|
private String templateName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package tech.unissense.pms.business.examine.task.service.impl;
|
package tech.unissense.pms.business.examine.task.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import tech.unissense.pms.business.examine.config.domain.ExamineConfig;
|
import tech.unissense.pms.business.examine.config.domain.ExamineConfig;
|
||||||
import tech.unissense.pms.business.examine.config.enums.ReviewTypeEnum;
|
import tech.unissense.pms.business.examine.config.enums.ReviewTypeEnum;
|
||||||
import tech.unissense.pms.business.examine.config.mapper.ExamineConfigMapper;
|
import tech.unissense.pms.business.examine.config.mapper.ExamineConfigMapper;
|
||||||
|
@ -31,6 +33,7 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class TaskServiceImpl implements TaskService {
|
public class TaskServiceImpl implements TaskService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -100,6 +103,22 @@ public class TaskServiceImpl implements TaskService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExamineTask updateTask(ExamineTask updatedTask) {
|
public ExamineTask updateTask(ExamineTask updatedTask) {
|
||||||
|
//如果模板变化 删除原有的指标项 重新生成
|
||||||
|
ExamineTask examineTask = examineTaskDao.queryById(updatedTask.getId());
|
||||||
|
if (!examineTask.getTemplateId().equals(updatedTask.getTemplateId())) {
|
||||||
|
//对应考核指标详情删除
|
||||||
|
detailService.deleteByTaskId(updatedTask.getId());
|
||||||
|
//对应考核指标项删除
|
||||||
|
examineConfigMapper.deleteByTaskId(updatedTask.getId());
|
||||||
|
//重新生成考核指标项
|
||||||
|
ExamineConfig examineConfig = new ExamineConfig();
|
||||||
|
examineConfig.setTemplateId(updatedTask.getTemplateId());
|
||||||
|
List<ExamineConfig> list = examineConfigMapper.list(examineConfig);
|
||||||
|
list.forEach(item -> {
|
||||||
|
item.setExamineTaskId(updatedTask.getId());
|
||||||
|
});
|
||||||
|
examineConfigMapper.insertBatch(list);
|
||||||
|
}
|
||||||
examineTaskDao.updateTask(updatedTask);
|
examineTaskDao.updateTask(updatedTask);
|
||||||
|
|
||||||
List<Integer> userIdList = updatedTask.getUserIdList();
|
List<Integer> userIdList = updatedTask.getUserIdList();
|
||||||
|
@ -114,7 +133,11 @@ public class TaskServiceImpl implements TaskService {
|
||||||
existingUsers.stream()
|
existingUsers.stream()
|
||||||
.filter(user -> !userIdList.contains(user.getUserId()))
|
.filter(user -> !userIdList.contains(user.getUserId()))
|
||||||
.forEach(user -> userMapper.deleteById(user.getId()));
|
.forEach(user -> userMapper.deleteById(user.getId()));
|
||||||
|
//删除对应考核指标详情
|
||||||
|
List<Integer> examineIdList = existingUsers.stream().filter(user -> !userIdList.contains(user.getUserId())).map(ExamineUser::getId).collect(Collectors.toList());
|
||||||
|
if (CollUtil.isNotEmpty(examineIdList)) {
|
||||||
|
detailService.deleteByExamineId(examineIdList);
|
||||||
|
}
|
||||||
// 2. 添加新的用户记录(只插入那些不在现有用户中的用户)
|
// 2. 添加新的用户记录(只插入那些不在现有用户中的用户)
|
||||||
userIdList.stream()
|
userIdList.stream()
|
||||||
.filter(userId -> !existingUserIds.contains(userId))
|
.filter(userId -> !existingUserIds.contains(userId))
|
||||||
|
|
|
@ -33,11 +33,13 @@ public class ExamineTemplate {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private Integer createBy;
|
private Integer createBy;
|
||||||
|
private String createByName;
|
||||||
/**
|
/**
|
||||||
* 更新者
|
* 更新者
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private Integer updateBy;
|
private Integer updateBy;
|
||||||
|
private String updateByName;
|
||||||
/**
|
/**
|
||||||
* 更新时间
|
* 更新时间
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -181,6 +181,9 @@
|
||||||
from pms_examine_config
|
from pms_examine_config
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
|
<delete id="deleteByTaskId">
|
||||||
|
delete from pms_examine_config where examine_task_id = #{examineTaskId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,10 @@
|
||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
<delete id="deleteByTaskId">
|
||||||
|
delete
|
||||||
|
from pms_examine_detail where config_id in (select id from pms_examine_config where examine_task_id=#{taskId});
|
||||||
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
|
|
@ -11,57 +11,58 @@
|
||||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||||
<result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
|
<result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
|
||||||
<result property="taskEditFlag" column="task_edit_flag" jdbcType="BOOLEAN"/>
|
<result property="taskEditFlag" column="task_edit_flag" jdbcType="BOOLEAN"/>
|
||||||
|
<result property="templateId" column="template_id" jdbcType="BOOLEAN"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<!-- 新增任务 -->
|
<!-- 新增任务 -->
|
||||||
<insert id="addTask" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
|
<insert id="addTask" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
|
||||||
INSERT INTO pms_examine_task (task_name, people_number, people_number_detail, task_status, create_time, end_time, year)
|
INSERT INTO pms_examine_task (task_name, people_number, people_number_detail, task_status, create_time, end_time, year,template_id)
|
||||||
VALUES (#{taskName}, #{peopleNumber}, #{peopleNumberDetail}, #{taskStatus}, #{createTime}, #{endTime}, #{year})
|
VALUES (#{taskName}, #{peopleNumber}, #{peopleNumberDetail}, #{taskStatus}, #{createTime}, #{endTime}, #{year},#{templateId})
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<select id="getTasks" resultMap="ExamineTaskMap">
|
<select id="getTasks" resultMap="ExamineTaskMap">
|
||||||
SELECT * FROM pms_examine_task
|
SELECT t1.*,t2.template_type,t2.template_name FROM pms_examine_task t1 left join pms_examine_template t2 on t1.template_id=t2.id
|
||||||
<where>
|
<where>
|
||||||
<if test="taskName != null and taskName != ''">
|
<if test="taskName != null and taskName != ''">
|
||||||
AND task_name LIKE CONCAT('%', #{taskName}, '%')
|
AND t1.task_name LIKE CONCAT('%', #{taskName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="taskStatus != null">
|
<if test="taskStatus != null">
|
||||||
<choose>
|
<choose>
|
||||||
<when test="taskStatus == 2">
|
<when test="taskStatus == 2">
|
||||||
AND end_time < NOW()
|
AND t1.end_time < NOW()
|
||||||
</when>
|
</when>
|
||||||
<when test="taskStatus == 0">
|
<when test="taskStatus == 0">
|
||||||
AND end_time > CURRENT_TIMESTAMP
|
AND t1.end_time > CURRENT_TIMESTAMP
|
||||||
</when>
|
</when>
|
||||||
</choose>
|
</choose>
|
||||||
</if>
|
</if>
|
||||||
<if test="year != null">
|
<if test="year != null">
|
||||||
AND year = #{year}
|
AND t1.year = #{year}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
order by create_time desc
|
order by create_time desc
|
||||||
</select>
|
</select>
|
||||||
<select id="listTask" resultMap="ExamineTaskMap">
|
<select id="listTask" resultMap="ExamineTaskMap">
|
||||||
select distinct t1.id,t1.task_name, t1.people_number,t1.task_edit_flag, t1.people_number_detail, t1.task_status, t1.create_time, t1.end_time
|
select distinct t1.id,t1.task_name, t1.people_number,t1.task_edit_flag, t1.people_number_detail, t1.task_status, t1.create_time, t1.end_time,t1.template_id
|
||||||
from pms_examine_task t1
|
from pms_examine_task t1
|
||||||
left join pms_examine_user t2 on t1.id = t2.task_id
|
left join pms_examine_user t2 on t1.id = t2.task_id
|
||||||
left join sys_user t3 on t2.user_id = t3.user_id
|
left join sys_user t3 on t2.user_id = t3.user_id
|
||||||
<where>
|
<where>
|
||||||
<if test="taskName != null and taskName != ''">
|
<if test="taskName != null and taskName != ''">
|
||||||
AND task_name LIKE CONCAT('%', #{taskName}, '%')
|
AND t1.task_name LIKE CONCAT('%', #{taskName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="taskStatus != null">
|
<if test="taskStatus != null">
|
||||||
<choose>
|
<choose>
|
||||||
<when test="taskStatus == 2">
|
<when test="taskStatus == 2">
|
||||||
AND end_time < NOW()
|
AND t1.end_time < NOW()
|
||||||
</when>
|
</when>
|
||||||
<when test="taskStatus == 0">
|
<when test="taskStatus == 0">
|
||||||
AND end_time > CURRENT_TIMESTAMP
|
AND t1.end_time > CURRENT_TIMESTAMP
|
||||||
</when>
|
</when>
|
||||||
</choose>
|
</choose>
|
||||||
</if>
|
</if>
|
||||||
<if test="year != null">
|
<if test="year != null">
|
||||||
AND year = #{year}
|
AND t1.year = #{year}
|
||||||
</if>
|
</if>
|
||||||
<!-- 数据范围过滤 -->
|
<!-- 数据范围过滤 -->
|
||||||
${params.dataScope}
|
${params.dataScope}
|
||||||
|
@ -69,8 +70,9 @@
|
||||||
order by t1.create_time desc
|
order by t1.create_time desc
|
||||||
</select>
|
</select>
|
||||||
<select id="queryById" resultMap="ExamineTaskMap">
|
<select id="queryById" resultMap="ExamineTaskMap">
|
||||||
SELECT * FROM pms_examine_task
|
SELECT t1.*,t2.template_name,t2.template_type FROM pms_examine_task t1
|
||||||
WHERE id = #{id}
|
left join pms_examine_template t2 on t1.template_id=t2.id
|
||||||
|
WHERE t1.id = #{id}
|
||||||
</select>
|
</select>
|
||||||
<select id="listTaskSelf" resultType="tech.unissense.pms.business.examine.task.domain.ExamineTaskDto">
|
<select id="listTaskSelf" resultType="tech.unissense.pms.business.examine.task.domain.ExamineTaskDto">
|
||||||
select t1.examine_status_self,t1.id as examine_id,
|
select t1.examine_status_self,t1.id as examine_id,
|
||||||
|
@ -90,6 +92,7 @@
|
||||||
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
<if test="endTime != null">end_time = #{endTime},</if>
|
<if test="endTime != null">end_time = #{endTime},</if>
|
||||||
<if test="year != null">year = #{year},</if>
|
<if test="year != null">year = #{year},</if>
|
||||||
|
<if test="templateId != null">template_id = #{templateId},</if>
|
||||||
</set>
|
</set>
|
||||||
WHERE id = #{id}
|
WHERE id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
|
@ -20,29 +20,33 @@
|
||||||
<!--通过实体作为筛选条件查询-->
|
<!--通过实体作为筛选条件查询-->
|
||||||
<select id="queryAll" resultMap="ExamineTemplateMap">
|
<select id="queryAll" resultMap="ExamineTemplateMap">
|
||||||
select
|
select
|
||||||
<include refid="Base_Column_List"/>
|
t1.id, t1.template_name, t1.template_type, t1.create_by, t1.update_by, t1.update_time, t1.create_time,
|
||||||
from pms_examine_template
|
t2.nick_name as create_by_name,
|
||||||
|
t3.nick_name as update_by_name
|
||||||
|
from pms_examine_template t1
|
||||||
|
left join sys_user t2 on t1.create_by=t2.user_id
|
||||||
|
left join sys_user t3 on t1.update_by=t3.user_id
|
||||||
<where>
|
<where>
|
||||||
<if test="id != null">
|
<if test="id != null">
|
||||||
and id = #{id}
|
and t1.id = #{id}
|
||||||
</if>
|
</if>
|
||||||
<if test="templateName != null and templateName != ''">
|
<if test="templateName != null and templateName != ''">
|
||||||
and template_name = #{templateName}
|
and t1.template_name = #{templateName}
|
||||||
</if>
|
</if>
|
||||||
<if test="templateType != null and templateType != ''">
|
<if test="templateType != null and templateType != ''">
|
||||||
and template_type = #{templateType}
|
and t1.template_type = #{templateType}
|
||||||
</if>
|
</if>
|
||||||
<if test="createBy != null">
|
<if test="createBy != null">
|
||||||
and create_by = #{createBy}
|
and t1.create_by = #{createBy}
|
||||||
</if>
|
</if>
|
||||||
<if test="updateBy != null">
|
<if test="updateBy != null">
|
||||||
and update_by = #{updateBy}
|
and t1.update_by = #{updateBy}
|
||||||
</if>
|
</if>
|
||||||
<if test="updateTime != null">
|
<if test="updateTime != null">
|
||||||
and update_time = #{updateTime}
|
and t1.update_time = #{updateTime}
|
||||||
</if>
|
</if>
|
||||||
<if test="createTime != null">
|
<if test="createTime != null">
|
||||||
and create_time = #{createTime}
|
and t1.create_time = #{createTime}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
Loading…
Reference in New Issue