add(feature/REQ-3714) 优化update,减少历史工种重复保存
This commit is contained in:
parent
ddacfb236c
commit
2bf1462388
@ -3,17 +3,21 @@ package cn.axzo.orgmanax.infra.config;
|
||||
import cn.axzo.foundation.dao.support.mysql.plugins.LimitInterceptor;
|
||||
import cn.axzo.foundation.enums.AppEnvEnum;
|
||||
import cn.axzo.foundation.web.support.AppRuntime;
|
||||
import cn.axzo.foundation.web.support.conditional.LocalCondition;
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.logging.stdout.StdOutImpl;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
@EnableTransactionManagement
|
||||
@MapperScan("cn.axzo.orgmanax.**.mapper")
|
||||
@ -50,4 +54,29 @@ public class MybatisPlusConfig {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public EntityMetaObjectHandler entityMetaObjectHandler() {
|
||||
return new EntityMetaObjectHandler();
|
||||
}
|
||||
|
||||
public static class EntityMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
public EntityMetaObjectHandler() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
this.fillStrategy(metaObject, "createAt", new Date());
|
||||
this.fillStrategy(metaObject, "updateAt", new Date());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
this.setFieldValByName("updateAt", new Date(), metaObject);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,16 +59,9 @@ public class WorkerProfessionSkillTagRepositoryImpl implements WorkerProfessionS
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<WorkerProfessionSkillTag> skillTags = workerProfessionSkillTagDao.listByIds(ids);
|
||||
if (CollUtil.isEmpty(skillTags)) {
|
||||
return ;
|
||||
}
|
||||
Date date = new Date();
|
||||
skillTags.forEach(skillTag -> {
|
||||
skillTag.setIsDelete(skillTag.getId());
|
||||
skillTag.setUpdateAt(date);
|
||||
});
|
||||
workerProfessionSkillTagDao.updateBatchById(skillTags);
|
||||
workerProfessionSkillTagDao.lambdaUpdate()
|
||||
.in(WorkerProfessionSkillTag::getId, ids)
|
||||
.setSql(" is_delete = id")
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,25 +49,19 @@ public class WorkerProfessionTagRepositoryImpl implements WorkerProfessionTagRep
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeByIds(List<Long> ids){
|
||||
public void removeByIds(List<Long> ids) {
|
||||
workerProfessionTagDao.removeByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(List<Long> ids){
|
||||
public void deleteByIds(List<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return ;
|
||||
}
|
||||
List<WorkerProfessionTag> workerProfessionTags = workerProfessionTagDao.listByIds(ids);
|
||||
if (CollUtil.isEmpty(workerProfessionTags)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
Date date = new Date();
|
||||
workerProfessionTags.forEach(workerProfessionTag -> {
|
||||
workerProfessionTag.setIsDelete(workerProfessionTag.getId());
|
||||
workerProfessionTag.setUpdateAt(date);
|
||||
});
|
||||
workerProfessionTagDao.updateBatchById(workerProfessionTags);
|
||||
workerProfessionTagDao.lambdaUpdate()
|
||||
.in(WorkerProfessionTag::getId, ids)
|
||||
.setSql(" is_delete = id")
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ public class DeletePlatTeamWorkerProcessor implements NodeUserProcessor {
|
||||
// 删除平台工人工种和技能标签
|
||||
DeleteWorkerProfession workerProfession = DeleteWorkerProfession.builder()
|
||||
.scene(TeamSceneEnum.PLAT_TEAM.name())
|
||||
.personIds(param.getPersonIds())
|
||||
.personIds(Sets.newHashSet(deleteTeamWorkerPersonIds))
|
||||
.isResign(Boolean.TRUE)
|
||||
.orgNodeId(nodeId)
|
||||
.build();
|
||||
|
||||
@ -60,7 +60,7 @@ public class OrgProjectWorkerProfessionFoundationServiceImpl implements OrgProje
|
||||
return;
|
||||
}
|
||||
// 记录工人当前的工种&技能标签历史
|
||||
historyFoundationService.recordHistory(req);
|
||||
// historyFoundationService.recordHistory(req);
|
||||
// 删除技能标签
|
||||
absoluteRemoveSkillTags(req);
|
||||
// 删除工种
|
||||
|
||||
@ -111,15 +111,12 @@ public class OrgWorkerHistoryFoundationServiceImpl implements OrgWorkerHistoryFo
|
||||
.jsonStrData(professionSkillTags)
|
||||
.build());
|
||||
}
|
||||
Date date = new Date();
|
||||
return WorkerProfessionHistory.builder()
|
||||
.personId(first.getPersonId())
|
||||
.orgNodeId(first.getOrgNodeId())
|
||||
.workspaceId(first.getWorkspaceId())
|
||||
.bizData(first.getBizData())
|
||||
.jsonContent(JSON.toJSONString(historyDataList))
|
||||
.createAt(date)
|
||||
.updateAt(date)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user