diff --git a/inventory-dao/src/main/java/com/rzyc/enums/PostPathConcat.java b/inventory-dao/src/main/java/com/rzyc/enums/PostPathConcat.java new file mode 100644 index 0000000..7532f2e --- /dev/null +++ b/inventory-dao/src/main/java/com/rzyc/enums/PostPathConcat.java @@ -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; + } +} diff --git a/inventory-dao/src/main/java/com/rzyc/enums/Split.java b/inventory-dao/src/main/java/com/rzyc/enums/Split.java new file mode 100644 index 0000000..7ff8f68 --- /dev/null +++ b/inventory-dao/src/main/java/com/rzyc/enums/Split.java @@ -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; + } + +} diff --git a/inventory-dao/src/main/java/com/rzyc/mapper/ent/EntPostMapper.java b/inventory-dao/src/main/java/com/rzyc/mapper/ent/EntPostMapper.java index 5119e38..d5c4b7b 100644 --- a/inventory-dao/src/main/java/com/rzyc/mapper/ent/EntPostMapper.java +++ b/inventory-dao/src/main/java/com/rzyc/mapper/ent/EntPostMapper.java @@ -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 { * */ ListselectNoDutyPost(); + + /** + * 批量插入企业岗位 + * @param list + * @param sysEnterpriseId + * @return int + * */ + int insertEntPostBatch(@Param("list") List list,@Param("sysEnterpriseId") String sysEnterpriseId); + } diff --git a/inventory-dao/src/main/java/com/rzyc/mapper/ent/InListItemMapper.java b/inventory-dao/src/main/java/com/rzyc/mapper/ent/InListItemMapper.java index 816acae..8b7cd7b 100644 --- a/inventory-dao/src/main/java/com/rzyc/mapper/ent/InListItemMapper.java +++ b/inventory-dao/src/main/java/com/rzyc/mapper/ent/InListItemMapper.java @@ -19,7 +19,7 @@ import java.util.List; @Repository public interface InListItemMapper extends BaseMapper { - List SelectContents(@Param("industryId") String industryId,@Param("listId")String listId); + List selectContents(@Param("industryId") String industryId, @Param("listId")String listId); /*通过行业查询清单信息*/ List findByIndustryId(@Param("industryId") String industryId); diff --git a/inventory-dao/src/main/java/com/rzyc/model/InPost.java b/inventory-dao/src/main/java/com/rzyc/model/InPost.java index c0f52db..9222b06 100644 --- a/inventory-dao/src/main/java/com/rzyc/model/InPost.java +++ b/inventory-dao/src/main/java/com/rzyc/model/InPost.java @@ -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; } diff --git a/inventory-dao/src/main/java/com/rzyc/model/ent/EntPost.java b/inventory-dao/src/main/java/com/rzyc/model/ent/EntPost.java index d8643e9..d8c5264 100644 --- a/inventory-dao/src/main/java/com/rzyc/model/ent/EntPost.java +++ b/inventory-dao/src/main/java/com/rzyc/model/ent/EntPost.java @@ -80,6 +80,18 @@ public class EntPost implements Serializable { @TableField(exist = false) private Listchildren; + @ApiModelProperty(value = "公共岗位id") + @TableField(exist = false) + private String publicPostId; + + public String getPublicPostId() { + return publicPostId; + } + + public void setPublicPostId(String publicPostId) { + this.publicPostId = publicPostId; + } + public List getChildren() { return children; } diff --git a/inventory-dao/src/main/resources/mapper/EntPostDutyMapper.xml b/inventory-dao/src/main/resources/mapper/EntPostDutyMapper.xml index 4515d16..9121d35 100644 --- a/inventory-dao/src/main/resources/mapper/EntPostDutyMapper.xml +++ b/inventory-dao/src/main/resources/mapper/EntPostDutyMapper.xml @@ -27,7 +27,7 @@ diff --git a/inventory-dao/src/main/resources/mapper/ent/EntPostMapper.xml b/inventory-dao/src/main/resources/mapper/ent/EntPostMapper.xml index 7b00cb8..2c29621 100644 --- a/inventory-dao/src/main/resources/mapper/ent/EntPostMapper.xml +++ b/inventory-dao/src/main/resources/mapper/ent/EntPostMapper.xml @@ -46,6 +46,7 @@ #{data.createTime},#{data.createBy}) + @@ -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 + + insert into ent_post (post_id,enterprise_id,`name`,post_path,create_time,public_post_id)values + + (#{list.uuid}, + #{sysEnterpriseId}, + #{list.publicPostName}, + #{list.publicPostPath}, + #{list.createTime}, + #{list.publicPostId}) + + + diff --git a/inventory-dao/src/main/resources/mapper/ent/InListItemMapper.xml b/inventory-dao/src/main/resources/mapper/ent/InListItemMapper.xml index 5fbf5a4..f24de01 100644 --- a/inventory-dao/src/main/resources/mapper/ent/InListItemMapper.xml +++ b/inventory-dao/src/main/resources/mapper/ent/InListItemMapper.xml @@ -45,7 +45,7 @@ item_basis, item_proof, item_law, sort_id, del_state,create_time, create_by, mod - select * from in_list_item where del_state = 1 and industry_id = #{industryId} diff --git a/inventory-ent/src/main/java/com/rzyc/controller/BaseController.java b/inventory-ent/src/main/java/com/rzyc/controller/BaseController.java index eaec662..db79b03 100644 --- a/inventory-ent/src/main/java/com/rzyc/controller/BaseController.java +++ b/inventory-ent/src/main/java/com/rzyc/controller/BaseController.java @@ -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 = inListItemMapper.SelectContents(industryId,null); + List inListItem = inListItemMapper.selectContents(industryId,null); List entLists = ObjectConversion.copy(inListItem,InEntList.class); if(null != entLists && entLists.size()>0){ for (InEntList in:entLists) { diff --git a/inventory-ent/src/main/java/com/rzyc/service/AssignmentTaskThread.java b/inventory-ent/src/main/java/com/rzyc/service/AssignmentTaskThread.java index 94e7b38..efcbfbc 100644 --- a/inventory-ent/src/main/java/com/rzyc/service/AssignmentTaskThread.java +++ b/inventory-ent/src/main/java/com/rzyc/service/AssignmentTaskThread.java @@ -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()); + ListinPostLists = 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 { diff --git a/inventory-ent/src/main/java/com/rzyc/service/PcBusinessService.java b/inventory-ent/src/main/java/com/rzyc/service/PcBusinessService.java index c3589af..df763db 100644 --- a/inventory-ent/src/main/java/com/rzyc/service/PcBusinessService.java +++ b/inventory-ent/src/main/java/com/rzyc/service/PcBusinessService.java @@ -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); Listposts = JSONArray.parseArray(JSONArray.toJSONString(jsonArray),EntPost.class); @@ -118,7 +117,7 @@ public class PcBusinessService extends BaseController { List> data = new ArrayList<>(); for(EntPost entPost : list){ if(StringUtils.isBlank(entPost.getParentId())){ - entPost.setParentId(""); + entPost.setParentId("company"); } Map entPostMap = new HashMap(); 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(); ListselectNoEntPostListUser = 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; diff --git a/inventory-ent/src/main/java/com/rzyc/service/SaveEntListThread.java b/inventory-ent/src/main/java/com/rzyc/service/SaveEntListThread.java index be63d41..7cefe97 100644 --- a/inventory-ent/src/main/java/com/rzyc/service/SaveEntListThread.java +++ b/inventory-ent/src/main/java/com/rzyc/service/SaveEntListThread.java @@ -53,7 +53,7 @@ public class SaveEntListThread implements Runnable{ * @throws Exception */ public void saveEntInList(String industryId,String companyId)throws Exception{ - List inListItem = inListItemMapper.SelectContents(industryId,null); + List inListItem = inListItemMapper.selectContents(industryId,null); List entLists = ObjectConversion.copy(inListItem,InEntList.class); for (InEntList in:entLists) { in.setEnterpriseId(companyId); diff --git a/inventory-ent/src/main/java/com/rzyc/service/SaveIndustryPostThread.java b/inventory-ent/src/main/java/com/rzyc/service/SaveIndustryPostThread.java new file mode 100644 index 0000000..0e4c7f7 --- /dev/null +++ b/inventory-ent/src/main/java/com/rzyc/service/SaveIndustryPostThread.java @@ -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 ListentPostDutyList = 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 = inPostMapper.selectByIndustryId(industryId); + //批量插入岗位 + entPostMapper.insertEntPostBatch(inPost,sysEnterpriseId); + + for (InPost i:inPost) { + //查询中间表企业岗位清单 + InPostItem inPostItems = inPostItemMapper.selectByPostId(i.getPublicPostId()); + + //批量插入企业岗位职责 + List 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(); + } +} \ No newline at end of file diff --git a/inventory-ent/src/main/resources/application.yml b/inventory-ent/src/main/resources/application.yml index a703748..a6560f0 100644 --- a/inventory-ent/src/main/resources/application.yml +++ b/inventory-ent/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: profiles: - active: prod #设定打包配置文件 + active: dev #设定打包配置文件 diff --git a/inventory-gov/src/main/java/com/rzyc/controller/BaseController.java b/inventory-gov/src/main/java/com/rzyc/controller/BaseController.java index a912f9a..60caa62 100644 --- a/inventory-gov/src/main/java/com/rzyc/controller/BaseController.java +++ b/inventory-gov/src/main/java/com/rzyc/controller/BaseController.java @@ -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 = inListItemMapper.SelectContents(industryId,null); + List inListItem = inListItemMapper.selectContents(industryId,null); List entLists = ObjectConversion.copy(inListItem,InEntList.class); for (InEntList in:entLists) { in.setEnterpriseId(companyId); diff --git a/inventory-gov/src/main/java/com/rzyc/controller/IndustryListController.java b/inventory-gov/src/main/java/com/rzyc/controller/IndustryListController.java index 95abcdb..33c311e 100644 --- a/inventory-gov/src/main/java/com/rzyc/controller/IndustryListController.java +++ b/inventory-gov/src/main/java/com/rzyc/controller/IndustryListController.java @@ -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> result = new SingleResult<>(); Pager pager = new Pager<>(); PageHelper.startPage(inListPageDto.getPage(),inListPageDto.getPageSize()); - Page page = (Page)inListItemMapper.SelectContents(inListPageDto.getIndustryId(),inListPageDto.getListId()); + Page page = (Page)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"; + } + + diff --git a/inventory-gov/src/main/java/com/rzyc/controller/MinWorkController.java b/inventory-gov/src/main/java/com/rzyc/controller/MinWorkController.java index c57f0b2..2d04671 100644 --- a/inventory-gov/src/main/java/com/rzyc/controller/MinWorkController.java +++ b/inventory-gov/src/main/java/com/rzyc/controller/MinWorkController.java @@ -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); diff --git a/inventory-gov/src/main/java/com/rzyc/controller/ent/PcCompanyController.java b/inventory-gov/src/main/java/com/rzyc/controller/ent/PcCompanyController.java index f6b68d4..2ede0d7 100644 --- a/inventory-gov/src/main/java/com/rzyc/controller/ent/PcCompanyController.java +++ b/inventory-gov/src/main/java/com/rzyc/controller/ent/PcCompanyController.java @@ -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; + } /** diff --git a/inventory-gov/src/main/java/com/rzyc/service/PcBusinessService.java b/inventory-gov/src/main/java/com/rzyc/service/PcBusinessService.java index 2b5fe20..6d5e4ab 100644 --- a/inventory-gov/src/main/java/com/rzyc/service/PcBusinessService.java +++ b/inventory-gov/src/main/java/com/rzyc/service/PcBusinessService.java @@ -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(); - Pageposts = (Page) inListItemMapper.SelectContents(industryId,listId); + Pageposts = (Page) inListItemMapper.selectContents(industryId,listId); singleResult.setDataPager(posts); return singleResult; } diff --git a/inventory-gov/src/main/java/com/rzyc/service/SaveEntListThread.java b/inventory-gov/src/main/java/com/rzyc/service/SaveEntListThread.java index be63d41..7cefe97 100644 --- a/inventory-gov/src/main/java/com/rzyc/service/SaveEntListThread.java +++ b/inventory-gov/src/main/java/com/rzyc/service/SaveEntListThread.java @@ -53,7 +53,7 @@ public class SaveEntListThread implements Runnable{ * @throws Exception */ public void saveEntInList(String industryId,String companyId)throws Exception{ - List inListItem = inListItemMapper.SelectContents(industryId,null); + List inListItem = inListItemMapper.selectContents(industryId,null); List entLists = ObjectConversion.copy(inListItem,InEntList.class); for (InEntList in:entLists) { in.setEnterpriseId(companyId); diff --git a/inventory-gov/src/main/java/com/rzyc/service/SaveIndustryPostThread.java b/inventory-gov/src/main/java/com/rzyc/service/SaveIndustryPostThread.java new file mode 100644 index 0000000..af402ba --- /dev/null +++ b/inventory-gov/src/main/java/com/rzyc/service/SaveIndustryPostThread.java @@ -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 ListentPostDutyList = 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 = sysEnterpriseMapper.findAll(); + for (SysEnterprise s:sysEnterprise) { + List 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 list = inListItemMapper.selectContents(null,inPostItems.getInPostItemId()); + for (InListItem ili:list) { + addEntPostDuty(ili,i.getUuid(),s.getSysenterpriseid()); + } + } + } + } + finishLastList(); + } + + public void doing(){ + List inPost = inPostMapper.selectByIndustryId(industryId); + //批量插入岗位 + entPostMapper.insertEntPostBatch(inPost,sysEnterpriseId); + + for (InPost i:inPost) { + //查询中间表企业岗位清单 + InPostItem inPostItems = inPostItemMapper.selectByPostId(i.getPublicPostId()); + + //批量插入企业岗位职责 + List 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(); + } +} \ No newline at end of file diff --git a/inventory-gov/src/main/resources/application.yml b/inventory-gov/src/main/resources/application.yml index a703748..a6560f0 100644 --- a/inventory-gov/src/main/resources/application.yml +++ b/inventory-gov/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: profiles: - active: prod #设定打包配置文件 + active: dev #设定打包配置文件 diff --git a/utils/src/main/java/com/common/utils/model/Result.java b/utils/src/main/java/com/common/utils/model/Result.java index 26b3c4c..cf0e09d 100644 --- a/utils/src/main/java/com/common/utils/model/Result.java +++ b/utils/src/main/java/com/common/utils/model/Result.java @@ -30,6 +30,7 @@ public class Result { public void setCode(int code) { this.code = code; } + public String getMessage() { return message; }