145 lines
4.1 KiB
Java
145 lines
4.1 KiB
Java
|
|
package com.rzyc.service;
|
|||
|
|
|
|||
|
|
|
|||
|
|
import com.alibaba.excel.util.ListUtils;
|
|||
|
|
import com.common.utils.RandomNumber;
|
|||
|
|
import com.rzyc.mapper.EntPostDutyMapper;
|
|||
|
|
import com.rzyc.mapper.InPostItemMapper;
|
|||
|
|
import com.rzyc.mapper.InPostListMapper;
|
|||
|
|
import com.rzyc.mapper.InPostMapper;
|
|||
|
|
import com.rzyc.mapper.ent.EntPostMapper;
|
|||
|
|
import com.rzyc.mapper.ent.InListItemMapper;
|
|||
|
|
import com.rzyc.mapper.ent.SysEnterpriseMapper;
|
|||
|
|
import com.rzyc.model.EntPostDuty;
|
|||
|
|
import com.rzyc.model.InPost;
|
|||
|
|
import com.rzyc.model.InPostItem;
|
|||
|
|
import com.rzyc.model.ent.InListItem;
|
|||
|
|
import com.rzyc.model.ent.SysEnterprise;
|
|||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|||
|
|
|
|||
|
|
import java.util.Date;
|
|||
|
|
import java.util.List;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 企业保存行业清单岗位
|
|||
|
|
* @author Xuwanxin
|
|||
|
|
* @date 2023/1/18
|
|||
|
|
* */
|
|||
|
|
public class SaveIndustryPostThread implements Runnable {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 公共岗位
|
|||
|
|
*/
|
|||
|
|
private InPostMapper inPostMapper;
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 公共岗位清单
|
|||
|
|
*/
|
|||
|
|
private InPostItemMapper inPostItemMapper;
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 公共岗位职责
|
|||
|
|
*/
|
|||
|
|
private InPostListMapper inPostListMapper;
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 公共行业履职清单
|
|||
|
|
*/
|
|||
|
|
private InListItemMapper inListItemMapper;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 企业表
|
|||
|
|
* */
|
|||
|
|
private SysEnterpriseMapper sysEnterpriseMapper;
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 企业表
|
|||
|
|
* */
|
|||
|
|
private EntPostMapper entPostMapper;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 企业岗位职责
|
|||
|
|
* */
|
|||
|
|
private EntPostDutyMapper entPostDutyMapper;
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 企业行业id
|
|||
|
|
* */
|
|||
|
|
private String industryId ;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 企业主键id
|
|||
|
|
* */
|
|||
|
|
private String sysEnterpriseId;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收
|
|||
|
|
*/
|
|||
|
|
private static final int BATCH_COUNT = 100;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 企业岗位职责-缓存数据
|
|||
|
|
* */
|
|||
|
|
private List<EntPostDuty>entPostDutyList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
|
|||
|
|
|
|||
|
|
@Autowired
|
|||
|
|
public SaveIndustryPostThread(String industryId, String sysEnterpriseId, InPostMapper inPostMapper, InPostItemMapper inPostItemMapper, InPostListMapper inPostListMapper,
|
|||
|
|
InListItemMapper inListItemMapper, SysEnterpriseMapper sysEnterpriseMapper, EntPostMapper entPostMapper, EntPostDutyMapper entPostDutyMapper) {
|
|||
|
|
this.industryId = industryId;
|
|||
|
|
this.inPostMapper = inPostMapper;
|
|||
|
|
this.inPostItemMapper = inPostItemMapper;
|
|||
|
|
this.inPostListMapper = inPostListMapper;
|
|||
|
|
this.inListItemMapper = inListItemMapper;
|
|||
|
|
this.sysEnterpriseMapper = sysEnterpriseMapper;
|
|||
|
|
this.entPostMapper = entPostMapper;
|
|||
|
|
this.entPostDutyMapper = entPostDutyMapper;
|
|||
|
|
this.sysEnterpriseId = sysEnterpriseId;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
public void doing(){
|
|||
|
|
List<InPost> inPost = inPostMapper.selectByIndustryId(industryId);
|
|||
|
|
//批量插入岗位
|
|||
|
|
entPostMapper.insertEntPostBatch(inPost,sysEnterpriseId);
|
|||
|
|
|
|||
|
|
for (InPost i:inPost) {
|
|||
|
|
//查询中间表企业岗位清单
|
|||
|
|
InPostItem inPostItems = inPostItemMapper.selectByPostId(i.getPublicPostId());
|
|||
|
|
|
|||
|
|
//批量插入企业岗位职责
|
|||
|
|
List<InListItem> list = inListItemMapper.selectContents(null,inPostItems.getInPostItemId());
|
|||
|
|
for (InListItem ili:list) {
|
|||
|
|
addEntPostDuty(ili,i.getUuid(),sysEnterpriseId);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void addEntPostDuty(InListItem ili,String postId,String sysEnterpriseId){
|
|||
|
|
if (entPostDutyList.size() == BATCH_COUNT){
|
|||
|
|
entPostDutyMapper.insertList(entPostDutyList);
|
|||
|
|
entPostDutyList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
|
|||
|
|
}else {
|
|||
|
|
EntPostDuty entPostDuty = new EntPostDuty();
|
|||
|
|
entPostDuty.setDutyId(RandomNumber.getUUid());
|
|||
|
|
entPostDuty.setPostId(postId);
|
|||
|
|
entPostDuty.setDutyItem(ili.getItemContent());
|
|||
|
|
entPostDuty.setSortId(ili.getSortId());
|
|||
|
|
entPostDuty.setEnterpriseId(sysEnterpriseId);
|
|||
|
|
entPostDuty.setCreateTime(new Date());
|
|||
|
|
entPostDuty.setCreateBy("导入");
|
|||
|
|
entPostDutyList.add(entPostDuty);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
@Override
|
|||
|
|
public void run() {
|
|||
|
|
doing();
|
|||
|
|
}
|
|||
|
|
}
|