企业岗位和企业岗位职责 批量生成 和 业务正常生成

This commit is contained in:
79493 2023-02-02 17:39:18 +08:00
parent d3d675309a
commit 3543f44863
24 changed files with 547 additions and 60 deletions

View File

@ -0,0 +1,29 @@
package com.rzyc.enums;
/**
* post_path 拼接
* @author Xuwanxin
* @date 2023/2/2
* */
public enum PostPathConcat {
//企业岗位
company("company");
/*******分界线********/
private String key;
PostPathConcat(String key) {
this.key = key;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
}

View File

@ -0,0 +1,29 @@
package com.rzyc.enums;
/**
* 拼接分隔符
* @author Xuwanxin
* @date 2023/2/2
**/
public enum Split {
//企业岗位
SPLIT(",");
/*******分界线********/
private String key;
Split(String key) {
this.key = key;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
}

View File

@ -1,5 +1,6 @@
package com.rzyc.mapper.ent;
import com.rzyc.model.InPost;
import com.rzyc.model.dto.AddOrUpdateEntPostDto;
import com.rzyc.model.ent.EntPost;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@ -68,4 +69,13 @@ public interface EntPostMapper extends BaseMapper<EntPost> {
* */
List<EntPost>selectNoDutyPost();
/**
* 批量插入企业岗位
* @param list
* @param sysEnterpriseId
* @return int
* */
int insertEntPostBatch(@Param("list") List<InPost> list,@Param("sysEnterpriseId") String sysEnterpriseId);
}

View File

@ -19,7 +19,7 @@ import java.util.List;
@Repository
public interface InListItemMapper extends BaseMapper<InListItem> {
List<InListItem> SelectContents(@Param("industryId") String industryId,@Param("listId")String listId);
List<InListItem> selectContents(@Param("industryId") String industryId, @Param("listId")String listId);
/*通过行业查询清单信息*/
List<InListItem> findByIndustryId(@Param("industryId") String industryId);

View File

@ -5,6 +5,8 @@ import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import com.common.utils.RandomNumber;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -58,7 +60,7 @@ public class InPost implements Serializable {
private String createBy;
@TableField("create_time")
private Date createTime;
private Date createTime = new Date();
@TableField("modify_by")
private String modifyBy;
@ -77,6 +79,14 @@ public class InPost implements Serializable {
@TableField("industry_id")
private String industryId;
@TableField(exist = false)
private String uuid = RandomNumber.getUUid();
public String getUuid() {
return uuid;
}
public String getIndustryId() {
return industryId;
}

View File

@ -80,6 +80,18 @@ public class EntPost implements Serializable {
@TableField(exist = false)
private List<EntPost>children;
@ApiModelProperty(value = "公共岗位id")
@TableField(exist = false)
private String publicPostId;
public String getPublicPostId() {
return publicPostId;
}
public void setPublicPostId(String publicPostId) {
this.publicPostId = publicPostId;
}
public List<EntPost> getChildren() {
return children;
}

View File

@ -27,7 +27,7 @@
<select id="selectEntUserPostDuty" resultMap="BaseResultMap">
select * from ent_post_duty where enterprise_id = #{enterpriseId} and post_id = #{postId}
select * from ent_post_duty where enterprise_id = #{enterpriseId} and post_id = #{postId} order by sort_id asc
</select>
<insert id="insertList">

View File

@ -46,6 +46,7 @@
#{data.createTime},#{data.createBy})
</insert>
<select id="getParentPost" resultMap="BaseResultMap">
select ep2.* from ent_post ep inner join ent_post ep2 on ep2.post_id = ep.parent_id where ep.post_id = #{postId}
</select>
@ -59,4 +60,16 @@
select ep.* from ent_post ep left join ent_post_duty epd on epd.post_id = ep.post_id where epd.duty_id is null
</select>
<insert id="insertEntPostBatch">
insert into ent_post (post_id,enterprise_id,`name`,post_path,create_time,public_post_id)values
<foreach collection="list" item="list" separator=",">
(#{list.uuid},
#{sysEnterpriseId},
#{list.publicPostName},
#{list.publicPostPath},
#{list.createTime},
#{list.publicPostId})
</foreach>
</insert>
</mapper>

View File

@ -45,7 +45,7 @@ item_basis, item_proof, item_law, sort_id, del_state,create_time, create_by, mod
</insert>
<select id="SelectContents" resultMap="BaseResultMap">
<select id="selectContents" resultMap="BaseResultMap">
select * from in_list_item where del_state = 1
<if test="null != industryId and '' != industryId">
and industry_id = #{industryId}

View File

@ -1,6 +1,5 @@
package com.rzyc.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.common.utils.*;
import com.common.utils.copy.ObjectConversion;
@ -10,17 +9,11 @@ import com.common.utils.jpush.Jpush;
import com.common.utils.orcode.QRCodeUtil;
import com.common.utils.upload.FileUpload;
import com.common.utils.jwt.JwtUtil;
import com.rzyc.bean.FactorDay;
import com.rzyc.bean.FactorYear;
import com.rzyc.bean.OaTaskTime;
import com.rzyc.bean.UserDepart;
import com.common.utils.model.Pager;
import com.github.pagehelper.Page;
import com.rzyc.bean.bigdata.user.PerformInfo;
import com.rzyc.bean.bigdata.user.UnitList;
import com.rzyc.bean.check.CheckList;
import com.rzyc.bean.check.CheckPerform;
import com.rzyc.bean.user.PerformProgress;
import com.rzyc.config.ConstantsConfigure;
import com.rzyc.enums.*;
import com.rzyc.mapper.*;
@ -37,15 +30,10 @@ import com.rzyc.model.check.BookEntHT;
import com.rzyc.model.check.ChkPerson;
import com.rzyc.model.ent.*;
import com.rzyc.model.user.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -553,9 +541,16 @@ public class BaseController {
@Autowired
protected InListMapper inListMapper;
@Autowired
protected InListItemMapper inListItemMapper;
@Autowired
protected InPostListMapper inPostListMapper;
@Autowired
protected InPostItemMapper inPostItemMapper;
/**
* 新都文件地址处理
@ -1915,7 +1910,7 @@ public class BaseController {
* @throws Exception
*/
public void saveEntInList(String industryId,String companyId)throws Exception{
List<InListItem> inListItem = inListItemMapper.SelectContents(industryId,null);
List<InListItem> inListItem = inListItemMapper.selectContents(industryId,null);
List<InEntList> entLists = ObjectConversion.copy(inListItem,InEntList.class);
if(null != entLists && entLists.size()>0){
for (InEntList in:entLists) {

View File

@ -12,11 +12,17 @@ import com.rzyc.controller.BaseController;
import com.rzyc.enums.DelState;
import com.rzyc.mapper.EntPostListMapper;
import com.rzyc.mapper.EntPostTaskMapper;
import com.rzyc.mapper.InPostItemMapper;
import com.rzyc.mapper.InPostListMapper;
import com.rzyc.mapper.ent.EntPostMapper;
import com.rzyc.mapper.ent.EntUserMapper;
import com.rzyc.mapper.ent.InEntListMapper;
import com.rzyc.model.EntPostList;
import com.rzyc.model.EntPostTask;
import com.rzyc.model.InPostItem;
import com.rzyc.model.InPostList;
import com.rzyc.model.dto.AddOrUpdateEntUserPostListDto;
import com.rzyc.model.ent.EntPost;
import com.rzyc.model.ent.EntUser;
import com.rzyc.model.ent.InEntList;
import com.rzyc.model.user.SysUser;
@ -48,7 +54,14 @@ public class AssignmentTaskThread implements Runnable{
private EntUserMapper entUserMapper;
public AssignmentTaskThread(String entUser, String enterpriseId, String postId, EntPostListMapper entPostListMapper, EntPostTaskMapper entPostTaskMapper,InEntListMapper inEntListMapper,String createByUserId,EntUserMapper entUserMapper) {
private InPostListMapper inPostListMapper;
private InPostItemMapper inPostItemMapper;
private EntPostMapper entPostMapper;
public AssignmentTaskThread(String entUser, String enterpriseId, String postId, EntPostListMapper entPostListMapper, EntPostTaskMapper entPostTaskMapper,
InEntListMapper inEntListMapper, String createByUserId, InPostListMapper inPostListMapper, InPostItemMapper inPostItemMapper,EntUserMapper entUserMapper, EntPostMapper entPostMapper) {
this.entUserId = entUser;
this.enterpriseId = enterpriseId;
this.postId = postId;
@ -57,6 +70,9 @@ public class AssignmentTaskThread implements Runnable{
this.inEntListMapper = inEntListMapper;
this.createByUserId = createByUserId;
this.entUserMapper = entUserMapper;
this.inPostListMapper = inPostListMapper;
this.inPostItemMapper = inPostItemMapper;
this.entPostMapper = entPostMapper;
}
@Override
@ -91,6 +107,23 @@ public class AssignmentTaskThread implements Runnable{
addOrUpdateEntUserPostTaskDto.setStandard(ie.getStandard());
insertListAndTask(addOrUpdateEntUserPostTaskDto,createByUserId);
}
//企业对应岗位的清单
EntPost entPost = entPostMapper.selectById(postId);
InPostItem inPostItem = inPostItemMapper.selectByPostId(entPost.getPublicPostId());
List<InPostList>inPostLists = inPostListMapper.selectByListId(null,inPostItem.getInPostItemId());
for (InPostList ipl:inPostLists) {
AddOrUpdateEntUserPostListDto addOrUpdateEntUserPostTaskDto = new AddOrUpdateEntUserPostListDto();
addOrUpdateEntUserPostTaskDto.setEntUserId(userId);
addOrUpdateEntUserPostTaskDto.setEnterpriseId(enterpriseId);
addOrUpdateEntUserPostTaskDto.setPostId(postId);
addOrUpdateEntUserPostTaskDto.setEntListId(ipl.getPublicPostListId());
addOrUpdateEntUserPostTaskDto.setFrequency(ipl.getFrequency());
addOrUpdateEntUserPostTaskDto.setItemContent(ipl.getPublicItemContent());
addOrUpdateEntUserPostTaskDto.setItemTitle(ipl.getPublicItemTitle());
addOrUpdateEntUserPostTaskDto.setListId(ipl.getListId());
addOrUpdateEntUserPostTaskDto.setStandard(ipl.getStandard());
insertListAndTask(addOrUpdateEntUserPostTaskDto,createByUserId);
}
}
private SingleResult insertListAndTask(AddOrUpdateEntUserPostListDto addOrUpdateEntUserPostTaskDto,String createByUserId) throws Exception {

View File

@ -14,7 +14,9 @@ import com.rzyc.advice.CustomException;
import com.rzyc.config.RedisUtil;
import com.rzyc.controller.BaseController;
import com.rzyc.enums.DelState;
import com.rzyc.enums.PostPathConcat;
import com.rzyc.enums.RedisKeys;
import com.rzyc.enums.Split;
import com.rzyc.model.*;
import com.rzyc.model.EasyExcel.EasyExcelEnterprise;
import com.rzyc.model.EasyExcel.EasyExcelInList;
@ -88,12 +90,9 @@ public class PcBusinessService extends BaseController {
EntPost entPost = new EntPost();
entPost.setName(sysEnterprise.getEntname());
entPost.setPostId("company");
entPost.setParentId("first");
list.add(entPost);
if (null != postId){
list.get(0).setParentId("company");
}
JSONArray jsonArray = handleEntUserTree(list);
List<EntPost>posts = JSONArray.parseArray(JSONArray.toJSONString(jsonArray),EntPost.class);
@ -118,7 +117,7 @@ public class PcBusinessService extends BaseController {
List<Map<String,Object>> data = new ArrayList<>();
for(EntPost entPost : list){
if(StringUtils.isBlank(entPost.getParentId())){
entPost.setParentId("");
entPost.setParentId("company");
}
Map<String,Object> entPostMap = new HashMap<String,Object>();
entPostMap.put("postId",entPost.getPostId());
@ -244,8 +243,9 @@ public class PcBusinessService extends BaseController {
EntUser entUser = new EntUser();
BeanUtils.copyProperties(addOrUpdateEntUserDto,entUser);
EntPost entPost = entPostMapper.selectById(addOrUpdateEntUserDto.getPostId());
entUser.setPostPath(entPost.getPostPath());
entUser.setPostPathName(entPost.getPostId());
entUser.setPostPath(new StringBuilder().append(PostPathConcat.company).append(Split.SPLIT.getKey()).append(entPost.getPostId()).toString());
entUser.setPostPathName(entPost.getPostPath());
entUser.setAccount(entUser.getMobile());
//密码为用户名加手机号
entUser.setPasswd(MD5.md5(entUser.getMobile()));
int result = 0 ;
@ -277,7 +277,7 @@ public class PcBusinessService extends BaseController {
entUserCredentialMapper.delEntUserCredential(entUser.getEntUserId());
}
//插入清单和任务
AssignmentTaskThread textThread = new AssignmentTaskThread(entUser.getEntUserId(),addOrUpdateEntUserDto.getEnterpriseId(),addOrUpdateEntUserDto.getPostId(),entPostListMapper,entPostTaskMapper,inEntListMapper,getUserId(),entUserMapper);
AssignmentTaskThread textThread = new AssignmentTaskThread(entUser.getEntUserId(),addOrUpdateEntUserDto.getEnterpriseId(),addOrUpdateEntUserDto.getPostId(),entPostListMapper,entPostTaskMapper,inEntListMapper,getUserId(),inPostListMapper,inPostItemMapper,entUserMapper,entPostMapper);
Thread thread=new Thread(textThread);
thread.start();
return singleResult;
@ -1264,7 +1264,7 @@ public class PcBusinessService extends BaseController {
SingleResult singleResult = new SingleResult();
List<EntUser>selectNoEntPostListUser = entUserMapper.selectNoEntPostListUser();
for (EntUser e:selectNoEntPostListUser) {
AssignmentTaskThread assignmentTaskThread = new AssignmentTaskThread(e.getEntUserId(),e.getEnterpriseId(),e.getPostId(),entPostListMapper,entPostTaskMapper,inEntListMapper,getUserId(),entUserMapper);
AssignmentTaskThread assignmentTaskThread = new AssignmentTaskThread(e.getEntUserId(),e.getEnterpriseId(),e.getPostId(),entPostListMapper,entPostTaskMapper,inEntListMapper,getUserId(),inPostListMapper,inPostItemMapper,entUserMapper,entPostMapper);
executor.execute(assignmentTaskThread);
}
return singleResult;

View File

@ -53,7 +53,7 @@ public class SaveEntListThread implements Runnable{
* @throws Exception
*/
public void saveEntInList(String industryId,String companyId)throws Exception{
List<InListItem> inListItem = inListItemMapper.SelectContents(industryId,null);
List<InListItem> inListItem = inListItemMapper.selectContents(industryId,null);
List<InEntList> entLists = ObjectConversion.copy(inListItem,InEntList.class);
for (InEntList in:entLists) {
in.setEnterpriseId(companyId);

View File

@ -0,0 +1,145 @@
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();
}
}

View File

@ -1,6 +1,6 @@
spring:
profiles:
active: prod #设定打包配置文件
active: dev #设定打包配置文件

View File

@ -499,6 +499,14 @@ public class BaseController {
@Autowired
protected InPostListMapper inPostListMapper;
//企业岗位职责
@Autowired
protected EntPostDutyMapper entPostDutyMapper;
//企业岗位任务
@Autowired
protected EntPostTaskMapper entPostTaskMapper;
/**
* 岗位不需要的字符串
@ -2797,7 +2805,7 @@ public class BaseController {
* @throws Exception
*/
public void saveEntInList(String industryId,String companyId)throws Exception{
List<InListItem> inListItem = inListItemMapper.SelectContents(industryId,null);
List<InListItem> inListItem = inListItemMapper.selectContents(industryId,null);
List<InEntList> entLists = ObjectConversion.copy(inListItem,InEntList.class);
for (InEntList in:entLists) {
in.setEnterpriseId(companyId);

View File

@ -15,17 +15,18 @@ import com.rzyc.model.ent.BaseInClass;
import com.rzyc.model.ent.InList;
import com.rzyc.model.ent.InListItem;
import com.rzyc.service.PcBusinessService;
import com.rzyc.service.SaveIndustryPostThread;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -116,7 +117,7 @@ public class IndustryListController extends BaseController{
SingleResult<Pager<String>> result = new SingleResult<>();
Pager<String> pager = new Pager<>();
PageHelper.startPage(inListPageDto.getPage(),inListPageDto.getPageSize());
Page<InListItem> page = (Page<InListItem>)inListItemMapper.SelectContents(inListPageDto.getIndustryId(),inListPageDto.getListId());
Page<InListItem> page = (Page<InListItem>)inListItemMapper.selectContents(inListPageDto.getIndustryId(),inListPageDto.getListId());
getDatePage(pager,page);
result.setData(pager);
return result;
@ -249,6 +250,22 @@ public class IndustryListController extends BaseController{
return pcBusinessService.getIndustryPostListTask(page,pageSize,industryId,inPostItem.getInPostItemId());
}
/**
* 将行业公共岗位的履职清单和岗位职责插入到对应企业
* @return
*/
@ApiOperation(value = "将行业公共岗位及岗位职责插入到对应企业", notes = "将行业公共岗位的履职清单和岗位职责插入到对应企业")
@GetMapping("/insertEntDutyAndEntList")
@ResponseBody
@Transactional
public String insertEntDutyAndEntList()throws Exception{
SaveIndustryPostThread saveIndustryPost = new SaveIndustryPostThread(null,null,inPostMapper,inPostItemMapper,inPostListMapper,inListItemMapper,sysEnterpriseMapper,entPostMapper, entPostDutyMapper);
Thread thread = new Thread(saveIndustryPost);
thread.start();
return "success";
}

View File

@ -29,6 +29,7 @@ import com.rzyc.model.user.SysUnit;
import com.rzyc.model.user.SysUser;
import com.rzyc.service.SaveEntListThread;
import com.rzyc.service.SaveEntPostAndUserThread;
import com.rzyc.service.SaveIndustryPostThread;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -2115,6 +2116,12 @@ public class MinWorkController extends BaseController{
sysEnterprise.setQrCode(entQrCode(sysEnterprise.getSysenterpriseid()));
result = sysEnterpriseMapper.insert(sysEnterprise);
//创建多个行业岗位
SaveIndustryPostThread saveIndustryPost = new SaveIndustryPostThread(null,null,inPostMapper,inPostItemMapper,inPostListMapper,inListItemMapper,sysEnterpriseMapper,entPostMapper, entPostDutyMapper);
Thread saveIndustryPostThread = new Thread(saveIndustryPost);
saveIndustryPostThread.start();
}else {
SysEnterprise verifyEnterprise = sysEnterpriseMapper.selectByName(sysEnterpriseDo.getEntname(),sysEnterpriseDo.getSysenterpriseid());
if (null != verifyEnterprise){
@ -2133,8 +2140,7 @@ public class MinWorkController extends BaseController{
SaveEntListThread saveEntListThread = new SaveEntListThread(inListItemMapper,inEntListMapper,getUserId(),sysEnterprise.getBaseinclassid(),sysEnterprise.getSysenterpriseid());
Thread thread = new Thread(saveEntListThread);
thread.start();
//创建或者修改企业用户
//用于判断手机号重复单加不影响
//创建法人账号用于判断手机号重复单加不影响
CopyOnWriteArrayList copyOnWriteArrayList = new CopyOnWriteArrayList();
SaveEntPostAndUserThread SaveEntPostAndUserThread = new SaveEntPostAndUserThread(sysEnterprise.getSysenterpriseid(),getUserId(),entPostMapper,entUserMapper,constantsConfigure,sysEnterprise.getLegalrepre(),sysEnterprise.getLrlinktel(),sysEnterprise.getEntname(),copyOnWriteArrayList);
Thread t = new Thread(SaveEntPostAndUserThread);

View File

@ -23,6 +23,8 @@ import com.rzyc.model.ent.SysEnterprise;
import com.rzyc.model.user.SysUnit;
import com.rzyc.model.user.SysUser;
import com.rzyc.service.SaveEntListThread;
import com.rzyc.service.SaveEntPostAndUserThread;
import com.rzyc.service.SaveIndustryPostThread;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -42,6 +44,7 @@ import java.sql.Timestamp;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
/**
@ -656,7 +659,10 @@ public class PcCompanyController extends com.rzyc.controller.BaseController {
sysEnterprise.setQrCode(entQrCode(sysEnterprise.getSysenterpriseid()));
sysEnterpriseMapper.insert(sysEnterprise);
handleEetUser(sysEnterprise.getSysenterpriseid());
//创建多个行业岗位
SaveIndustryPostThread saveIndustryPost = new SaveIndustryPostThread(null,null,inPostMapper,inPostItemMapper,inPostListMapper,inListItemMapper,sysEnterpriseMapper,entPostMapper, entPostDutyMapper);
Thread saveIndustryPostThread = new Thread(saveIndustryPost);
saveIndustryPostThread.start();
}else {
SysEnterprise verifyEnterprise = sysEnterpriseMapper.selectByName(sysEnterpriseDo.getEntname(),sysEnterpriseDo.getSysenterpriseid());
if (null != verifyEnterprise){
@ -678,7 +684,8 @@ public class PcCompanyController extends com.rzyc.controller.BaseController {
}
//生成最小工作单元
/** 注释时间2023/2/2 xuwanxin
* //生成最小工作单元
saveEntWork(sysEnterprise.getSysenterpriseid());
//生成行业对应的企业责任清单
SaveEntListThread saveEntListThread = new SaveEntListThread(inListItemMapper,inEntListMapper,getUserId(),sysEnterprise.getBaseinclassid(),sysEnterprise.getSysenterpriseid());
@ -689,12 +696,33 @@ public class PcCompanyController extends com.rzyc.controller.BaseController {
//生成行业对应的企业责任清单
saveEntInList(sysEnterprise.getWorkClassId(),sysEnterprise.getSysenterpriseid());
//创建或者修改企业用户
// createEntUser(sysEnterprise,sysUser.getChinaname(),sysUser);
createEntUser(sysEnterprise,sysUser.getChinaname(),sysUser);
//生成清单
handleEntList(sysEnterprise.getSysenterpriseid());
handleEntList(sysEnterprise.getSysenterpriseid());*/
//生成最小工作单元
saveEntWork(sysEnterprise.getSysenterpriseid());
//生成行业对应的企业责任清单
SaveEntListThread saveEntListThread = new SaveEntListThread(inListItemMapper,inEntListMapper,getUserId(),sysEnterprise.getBaseinclassid(),sysEnterprise.getSysenterpriseid());
Thread thread = new Thread(saveEntListThread);
thread.start();
//创建法人账号用于判断手机号重复单加不影响
CopyOnWriteArrayList copyOnWriteArrayList = new CopyOnWriteArrayList();
SaveEntPostAndUserThread SaveEntPostAndUserThread = new SaveEntPostAndUserThread(sysEnterprise.getSysenterpriseid(),getUserId(),entPostMapper,entUserMapper,constantsConfigure,sysEnterprise.getLegalrepre(),sysEnterprise.getLrlinktel(),sysEnterprise.getEntname(),copyOnWriteArrayList);
Thread t = new Thread(SaveEntPostAndUserThread);
t.start();
if (result > 0){
singleResult.setMessage(Message.SUCCESS);
singleResult.setCode(Code.SUCCESS.getCode());
}else {
singleResult.setMessage(Message.ERROR);
singleResult.setCode(Code.ERROR.getCode());
}
return singleResult;
}
/**

View File

@ -1,39 +1,20 @@
package com.rzyc.service;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.common.utils.Arith;
import com.common.utils.RandomNumber;
import com.common.utils.StringUtils;
import com.common.utils.TypeConversion;
import com.common.utils.encryption.MD5;
import com.common.utils.model.Code;
import com.common.utils.model.Message;
import com.common.utils.model.SingleResult;
import com.common.utils.pager.PageOperation;
import com.github.pagehelper.Page;
import com.rzyc.advice.CustomException;
import com.rzyc.config.RedisUtil;
import com.rzyc.controller.BaseController;
import com.rzyc.enums.DelState;
import com.rzyc.enums.RedisKeys;
import com.rzyc.model.*;
import com.rzyc.model.EasyExcel.EasyExcelEnterprise;
import com.rzyc.model.EasyExcel.EasyExcelPostList;
import com.rzyc.model.dto.*;
import com.rzyc.model.ent.*;
import com.rzyc.utils.easyexcel.EntEnterprisePostListener;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 企业端pc业务 Service
@ -71,7 +52,7 @@ public class PcBusinessService extends BaseController {
@PageOperation
public SingleResult getIndustryPostDuty(Integer page , Integer pageSize ,String industryId,String listId){
SingleResult singleResult = new SingleResult();
Page<InListItem>posts = (Page<InListItem>) inListItemMapper.SelectContents(industryId,listId);
Page<InListItem>posts = (Page<InListItem>) inListItemMapper.selectContents(industryId,listId);
singleResult.setDataPager(posts);
return singleResult;
}

View File

@ -53,7 +53,7 @@ public class SaveEntListThread implements Runnable{
* @throws Exception
*/
public void saveEntInList(String industryId,String companyId)throws Exception{
List<InListItem> inListItem = inListItemMapper.SelectContents(industryId,null);
List<InListItem> inListItem = inListItemMapper.selectContents(industryId,null);
List<InEntList> entLists = ObjectConversion.copy(inListItem,InEntList.class);
for (InEntList in:entLists) {
in.setEnterpriseId(companyId);

View File

@ -0,0 +1,170 @@
package com.rzyc.service;
import com.alibaba.excel.util.ListUtils;
import com.common.utils.RandomNumber;
import com.rzyc.mapper.*;
import com.rzyc.mapper.ent.EntPostMapper;
import com.rzyc.mapper.ent.InListItemMapper;
import com.rzyc.mapper.ent.SysEnterpriseMapper;
import com.rzyc.model.*;
import com.rzyc.model.EasyExcel.EasyExcelEnterprise;
import com.rzyc.model.ent.InEntList;
import com.rzyc.model.ent.InListItem;
import com.rzyc.model.ent.SysEnterprise;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
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 batchSave(){
List<SysEnterprise> sysEnterprise = sysEnterpriseMapper.findAll();
for (SysEnterprise s:sysEnterprise) {
List<InPost> inPost = inPostMapper.selectByIndustryId(s.getWorkClassId());
if (null != inPost && inPost.size() > 0){
//批量插入岗位
entPostMapper.insertEntPostBatch(inPost,s.getSysenterpriseid());
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(),s.getSysenterpriseid());
}
}
}
}
finishLastList();
}
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);
}
}
private void finishLastList(){
entPostDutyMapper.insertList(entPostDutyList);
entPostDutyList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
@Override
public void run() {
batchSave();
}
}

View File

@ -1,6 +1,6 @@
spring:
profiles:
active: prod #设定打包配置文件
active: dev #设定打包配置文件

View File

@ -30,6 +30,7 @@ public class Result {
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}