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.dao.support.mysql.plugins.LimitInterceptor;
|
||||||
import cn.axzo.foundation.enums.AppEnvEnum;
|
import cn.axzo.foundation.enums.AppEnvEnum;
|
||||||
import cn.axzo.foundation.web.support.AppRuntime;
|
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.annotation.DbType;
|
||||||
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
|
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.MybatisPlusInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.ibatis.logging.stdout.StdOutImpl;
|
import org.apache.ibatis.logging.stdout.StdOutImpl;
|
||||||
|
import org.apache.ibatis.reflection.MetaObject;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@MapperScan("cn.axzo.orgmanax.**.mapper")
|
@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)) {
|
if (CollUtil.isEmpty(ids)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
workerProfessionSkillTagDao.lambdaUpdate()
|
||||||
List<WorkerProfessionSkillTag> skillTags = workerProfessionSkillTagDao.listByIds(ids);
|
.in(WorkerProfessionSkillTag::getId, ids)
|
||||||
if (CollUtil.isEmpty(skillTags)) {
|
.setSql(" is_delete = id")
|
||||||
return ;
|
.update();
|
||||||
}
|
|
||||||
Date date = new Date();
|
|
||||||
skillTags.forEach(skillTag -> {
|
|
||||||
skillTag.setIsDelete(skillTag.getId());
|
|
||||||
skillTag.setUpdateAt(date);
|
|
||||||
});
|
|
||||||
workerProfessionSkillTagDao.updateBatchById(skillTags);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,16 +58,10 @@ public class WorkerProfessionTagRepositoryImpl implements WorkerProfessionTagRep
|
|||||||
if (CollUtil.isEmpty(ids)) {
|
if (CollUtil.isEmpty(ids)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<WorkerProfessionTag> workerProfessionTags = workerProfessionTagDao.listByIds(ids);
|
|
||||||
if (CollUtil.isEmpty(workerProfessionTags)) {
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
Date date = new Date();
|
workerProfessionTagDao.lambdaUpdate()
|
||||||
workerProfessionTags.forEach(workerProfessionTag -> {
|
.in(WorkerProfessionTag::getId, ids)
|
||||||
workerProfessionTag.setIsDelete(workerProfessionTag.getId());
|
.setSql(" is_delete = id")
|
||||||
workerProfessionTag.setUpdateAt(date);
|
.update();
|
||||||
});
|
|
||||||
workerProfessionTagDao.updateBatchById(workerProfessionTags);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -162,7 +162,7 @@ public class DeletePlatTeamWorkerProcessor implements NodeUserProcessor {
|
|||||||
// 删除平台工人工种和技能标签
|
// 删除平台工人工种和技能标签
|
||||||
DeleteWorkerProfession workerProfession = DeleteWorkerProfession.builder()
|
DeleteWorkerProfession workerProfession = DeleteWorkerProfession.builder()
|
||||||
.scene(TeamSceneEnum.PLAT_TEAM.name())
|
.scene(TeamSceneEnum.PLAT_TEAM.name())
|
||||||
.personIds(param.getPersonIds())
|
.personIds(Sets.newHashSet(deleteTeamWorkerPersonIds))
|
||||||
.isResign(Boolean.TRUE)
|
.isResign(Boolean.TRUE)
|
||||||
.orgNodeId(nodeId)
|
.orgNodeId(nodeId)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@ -60,7 +60,7 @@ public class OrgProjectWorkerProfessionFoundationServiceImpl implements OrgProje
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 记录工人当前的工种&技能标签历史
|
// 记录工人当前的工种&技能标签历史
|
||||||
historyFoundationService.recordHistory(req);
|
// historyFoundationService.recordHistory(req);
|
||||||
// 删除技能标签
|
// 删除技能标签
|
||||||
absoluteRemoveSkillTags(req);
|
absoluteRemoveSkillTags(req);
|
||||||
// 删除工种
|
// 删除工种
|
||||||
|
|||||||
@ -111,15 +111,12 @@ public class OrgWorkerHistoryFoundationServiceImpl implements OrgWorkerHistoryFo
|
|||||||
.jsonStrData(professionSkillTags)
|
.jsonStrData(professionSkillTags)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
Date date = new Date();
|
|
||||||
return WorkerProfessionHistory.builder()
|
return WorkerProfessionHistory.builder()
|
||||||
.personId(first.getPersonId())
|
.personId(first.getPersonId())
|
||||||
.orgNodeId(first.getOrgNodeId())
|
.orgNodeId(first.getOrgNodeId())
|
||||||
.workspaceId(first.getWorkspaceId())
|
.workspaceId(first.getWorkspaceId())
|
||||||
.bizData(first.getBizData())
|
.bizData(first.getBizData())
|
||||||
.jsonContent(JSON.toJSONString(historyDataList))
|
.jsonContent(JSON.toJSONString(historyDataList))
|
||||||
.createAt(date)
|
|
||||||
.updateAt(date)
|
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user