ganzi-api/inventory-ent/src/main/java/com/rzyc/service/EntPostDutyThread.java

59 lines
1.8 KiB
Java

package com.rzyc.service;
import com.common.utils.RandomNumber;
import com.rzyc.mapper.EntPostDutyMapper;
import com.rzyc.mapper.ent.InEntListMapper;
import com.rzyc.model.EntPostDuty;
import com.rzyc.model.ent.EntPost;
import com.rzyc.model.ent.InEntList;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 插入企业岗位职责
* @author xuwanxin
* @date 2022/12/22
* */
public class EntPostDutyThread implements Runnable{
private InEntListMapper inEntListMapper;
private EntPostDutyMapper entPostDutyMapper;
private List<EntPost>posts;
public EntPostDutyThread(InEntListMapper inEntListMapper, EntPostDutyMapper entPostDutyMapper,List<EntPost>posts) {
this.inEntListMapper = inEntListMapper;
this.entPostDutyMapper = entPostDutyMapper;
this.posts = posts;
}
@Override
public void run() {
List<EntPostDuty> duties = new ArrayList<>();
for (EntPost e:posts) {
List<InEntList> list = inEntListMapper.selectByEnterpriseId(e.getEnterpriseId());
for (InEntList s:list) {
EntPostDuty entPostDuty = new EntPostDuty();
entPostDuty.setDutyId(RandomNumber.getUUid());
entPostDuty.setPostId(e.getPostId());
entPostDuty.setDutyItem(s.getItemContent());
entPostDuty.setSortId(s.getSortId());
entPostDuty.setEnterpriseId(s.getEnterpriseId());
entPostDuty.setCreateBy("系统导入");
entPostDuty.setCreateTime(new Date());
duties.add(entPostDuty);
}
if (duties.size() > 0){
entPostDutyMapper.insertList(duties);
duties.clear();
}else {
System.out.println("err");
}
}
}
}