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 279ae6f..6ebefbf 100644 --- a/inventory-ent/src/main/java/com/rzyc/controller/BaseController.java +++ b/inventory-ent/src/main/java/com/rzyc/controller/BaseController.java @@ -551,6 +551,8 @@ public class BaseController { @Autowired protected InPostItemMapper inPostItemMapper; + @Autowired + protected InPostMapper inPostMapper; //企业周边情况 @Autowired diff --git a/inventory-ent/src/main/java/com/rzyc/controller/PersonalController.java b/inventory-ent/src/main/java/com/rzyc/controller/PersonalController.java index b18af3c..bef6e63 100644 --- a/inventory-ent/src/main/java/com/rzyc/controller/PersonalController.java +++ b/inventory-ent/src/main/java/com/rzyc/controller/PersonalController.java @@ -570,6 +570,21 @@ public class PersonalController extends BaseController{ + /** + * 生成企业行业清单(未生成的企业) + * + * */ + @ApiOperation(value = "生成企业行业清单(未生成的企业)", notes = "生成企业行业清单(未生成的企业)") + @GetMapping("/importInEntList") + @ResponseBody + public String importInEntList() throws Exception { + Listenterprises = sysEnterpriseMapper.selectNoEntList(); + for (SysEnterprise s:enterprises) { + saveEntInList(s.getBaseinclassid(),s.getSysenterpriseid()); + } + return "success"; + } + /** * 生成企业法人岗位和法人用户(未生产的企业) * @return list @@ -583,6 +598,9 @@ public class PersonalController extends BaseController{ } + + + /** * 生成企业岗位清单和岗位任务 * @return list 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 7238937..b7f56b3 100644 --- a/inventory-ent/src/main/java/com/rzyc/service/AssignmentTaskThread.java +++ b/inventory-ent/src/main/java/com/rzyc/service/AssignmentTaskThread.java @@ -8,7 +8,6 @@ import com.common.utils.model.Code; import com.common.utils.model.Message; import com.common.utils.model.SingleResult; import com.rzyc.bean.OaTaskTime; -import com.rzyc.controller.BaseController; import com.rzyc.enums.DelState; import com.rzyc.mapper.EntPostListMapper; import com.rzyc.mapper.EntPostTaskMapper; @@ -25,7 +24,6 @@ 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; import org.springframework.beans.BeanUtils; import java.util.*; @@ -35,7 +33,7 @@ import java.util.*; * @author Xuwanxin * @date 2022/12/8 * */ -public class AssignmentTaskThread implements Runnable{ +public class AssignmentTaskThread implements Runnable{ private String entUserId; @@ -61,7 +59,7 @@ public class AssignmentTaskThread implements Runnable{ 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) { + InEntListMapper inEntListMapper, String createByUserId, InPostListMapper inPostListMapper, InPostItemMapper inPostItemMapper, EntUserMapper entUserMapper, EntPostMapper entPostMapper) { this.entUserId = entUser; this.enterpriseId = enterpriseId; this.postId = postId; @@ -107,23 +105,7 @@ 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 { @@ -134,8 +116,8 @@ public class AssignmentTaskThread implements Runnable{ entPostList.setCreateBy(createByUserId); entPostList.setCreateTime(new Date()); entPostList.setDelState(DelState.NOT_DEL.getState()); - //默认当前年 entPostList.setPostListId(RandomNumber.getUUid()); + //默认清单时间当前年 entPostList.setYearNum(calendar.get(Calendar.YEAR)); int result = entPostListMapper.insert(entPostList); if (result != 1 ){ 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 763efe0..4e43c9b 100644 --- a/inventory-ent/src/main/java/com/rzyc/service/PcBusinessService.java +++ b/inventory-ent/src/main/java/com/rzyc/service/PcBusinessService.java @@ -848,7 +848,6 @@ public class PcBusinessService extends BaseController { double finishPercent = Arith.div(finishCount,total) * 100; singleResult.setData(new BigDecimal(finishPercent).setScale(2, RoundingMode.DOWN).doubleValue()); } - return singleResult; } @@ -1278,14 +1277,17 @@ public class PcBusinessService extends BaseController { SingleResult singleResult = new SingleResult(); ListsysEnterprises = sysEnterpriseMapper.selectNoLegalPersonPost(); CopyOnWriteArrayList copyOnWriteArrayList = new CopyOnWriteArrayList(); - for (SysEnterprise s:sysEnterprises) { + for (SysEnterprise sysEnterprise:sysEnterprises) { //创建或者修改企业用户 String userId = RandomNumber.getUUid(); String postId = RandomNumber.getUUid(); - SaveEntPostAndUserThread SaveEntPostAndUserThread = new SaveEntPostAndUserThread(s.getSysenterpriseid(),getUserId(),entPostMapper,entUserMapper,constantsConfigure,s.getLegalrepre(), - s.getLrlinktel(),s.getEntname(),copyOnWriteArrayList,postId,userId); + SaveEntPostAndUserThread SaveEntPostAndUserThread = new SaveEntPostAndUserThread(sysEnterprise.getSysenterpriseid(),getUserId(),sysEnterprise.getWorkClassId(),entPostMapper,entUserMapper,constantsConfigure,sysEnterprise.getLegalrepre(),sysEnterprise.getLrlinktel(),sysEnterprise.getEntname(),userId,postId,copyOnWriteArrayList,inListMapper,inListItemMapper,entPostDutyMapper); executor.execute(SaveEntPostAndUserThread); + + //创建多个行业岗位 + SaveIndustryPostThread saveIndustryPost = new SaveIndustryPostThread(sysEnterprise.getWorkClassId(),sysEnterprise.getSysenterpriseid(),inPostMapper,inPostItemMapper,inPostListMapper,inListItemMapper,sysEnterpriseMapper,entPostMapper, entPostDutyMapper,false); + executor.execute(saveIndustryPost); } 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 1a25c71..5411efd 100644 --- a/inventory-ent/src/main/java/com/rzyc/service/SaveEntListThread.java +++ b/inventory-ent/src/main/java/com/rzyc/service/SaveEntListThread.java @@ -2,6 +2,7 @@ package com.rzyc.service; import com.common.utils.RandomNumber; import com.common.utils.copy.ObjectConversion; +import com.rzyc.enums.PostListType; import com.rzyc.mapper.ent.InEntListMapper; import com.rzyc.mapper.ent.InListItemMapper; import com.rzyc.model.ent.InEntList; @@ -53,7 +54,7 @@ public class SaveEntListThread implements Runnable{ * @throws Exception */ public void saveEntInList(String industryId,String companyId)throws Exception{ - List inListItem = inListItemMapper.selectContents(industryId,null,null); + List inListItem = inListItemMapper.selectContents(industryId,null, PostListType.LIST_TYPE_NO.getType()); 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/SaveEntPostAndUserThread.java b/inventory-ent/src/main/java/com/rzyc/service/SaveEntPostAndUserThread.java index ceeca9f..522834d 100644 --- a/inventory-ent/src/main/java/com/rzyc/service/SaveEntPostAndUserThread.java +++ b/inventory-ent/src/main/java/com/rzyc/service/SaveEntPostAndUserThread.java @@ -1,18 +1,24 @@ package com.rzyc.service; +import com.alibaba.excel.util.ListUtils; import com.common.utils.RandomNumber; import com.common.utils.encryption.MD5; import com.rzyc.config.ConstantsConfigure; +import com.rzyc.enums.PostListType; import com.rzyc.mapper.EntPostDutyMapper; import com.rzyc.mapper.ent.EntPostMapper; import com.rzyc.mapper.ent.EntUserMapper; -import com.rzyc.mapper.ent.InEntListMapper; +import com.rzyc.mapper.ent.InListItemMapper; +import com.rzyc.mapper.ent.InListMapper; import com.rzyc.model.EntPostDuty; +import com.rzyc.model.InPost; +import com.rzyc.model.InPostItem; import com.rzyc.model.ent.EntPost; import com.rzyc.model.ent.EntUser; -import com.rzyc.model.ent.InEntList; +import com.rzyc.model.ent.InList; +import com.rzyc.model.ent.InListItem; +import com.rzyc.utils.SpringUtil; -import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -45,21 +51,39 @@ public class SaveEntPostAndUserThread implements Runnable { private String entName; - private CopyOnWriteArrayList copyOnWriteArrayList; - private String userId; + private String industryId; + private String postId; + private CopyOnWriteArrayList copyOnWriteArrayList; + + private InListMapper inListMapper; + + private InListItemMapper inListItemMapper; + + private EntPostDutyMapper entPostDutyMapper; + + /** + * 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收 + */ + private static final int BATCH_COUNT = 100; + + /** + * 企业岗位职责-缓存数据 + * */ + private ListentPostDutyList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT); - - public SaveEntPostAndUserThread(String enterpriseId, String createBy, EntPostMapper entPostMapper, EntUserMapper entUserMapper, ConstantsConfigure constantsConfigure, - String name, String phone, String entName, CopyOnWriteArrayList copyOnWriteArrayList, String postId, String userId) { + public SaveEntPostAndUserThread(String enterpriseId, String createBy, String industryId,EntPostMapper entPostMapper, EntUserMapper entUserMapper, ConstantsConfigure constantsConfigure, + String name, String phone, String entName,String userId,String postId, CopyOnWriteArrayList copyOnWriteArrayList, + InListMapper inListMapper,InListItemMapper inListItemMapper,EntPostDutyMapper entPostDutyMapper) { this.enterpriseId = enterpriseId; if (null != createBy){ this.createBy = createBy; } + this.industryId = industryId; this.entPostMapper = entPostMapper; this.entUserMapper = entUserMapper; this.constantsConfigure = constantsConfigure; @@ -67,8 +91,11 @@ public class SaveEntPostAndUserThread implements Runnable { this.phone = phone; this.entName = entName; this.copyOnWriteArrayList = copyOnWriteArrayList; - this.postId = postId; this.userId = userId; + this.postId = postId; + this.inListMapper = inListMapper; + this.inListItemMapper = inListItemMapper; + this.entPostDutyMapper = entPostDutyMapper; } @Override @@ -93,7 +120,6 @@ public class SaveEntPostAndUserThread implements Runnable { entPostMapper.deletePostOfLegalPerson(legalPerson,enterpriseId); entPostMapper.insertEntPost(entPost); - //存企业用户 EntUser entUser = new EntUser(); entUser.setEntUserId(userId); @@ -118,6 +144,44 @@ public class SaveEntPostAndUserThread implements Runnable { copyOnWriteArrayList.add(phone); entUserMapper.deleteLegalPerson(legalPerson,enterpriseId); entUserMapper.insert(entUser); + } + + + public void doing(){ + List inLists = inListMapper.findAll(industryId); + for (InList i:inLists) { + //批量插入企业岗位职责 + List list = inListItemMapper.selectContents(null,i.getListId(), PostListType.LIST_TYPE_NO.getType()); + for (InListItem ili:list) { + addEntPostDuty(ili,postId,enterpriseId); + } + } + finishLastList(); + } + + + 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(){ + if (null != entPostDutyList && entPostDutyList.size() > 0){ + entPostDutyMapper.insertList(entPostDutyList); + entPostDutyList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT); + } } } diff --git a/inventory-ent/src/main/java/com/rzyc/service/SaveIndustryPostThread.java b/inventory-ent/src/main/java/com/rzyc/service/SaveIndustryPostThread.java index 1e30664..321b765 100644 --- a/inventory-ent/src/main/java/com/rzyc/service/SaveIndustryPostThread.java +++ b/inventory-ent/src/main/java/com/rzyc/service/SaveIndustryPostThread.java @@ -3,20 +3,20 @@ 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.enums.PostListType; +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.EntPostDuty; -import com.rzyc.model.InPost; -import com.rzyc.model.InPostItem; +import com.rzyc.model.*; +import com.rzyc.model.EasyExcel.EasyExcelEnterprise; +import com.rzyc.model.ent.InEntList; +import com.rzyc.model.ent.InList; 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; @@ -77,6 +77,8 @@ public class SaveIndustryPostThread implements Runnable { * */ private String sysEnterpriseId; + private boolean batch; + /** * 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收 */ @@ -88,8 +90,8 @@ public class SaveIndustryPostThread implements Runnable { 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) { + public SaveIndustryPostThread(String industryId,String sysEnterpriseId,InPostMapper inPostMapper, InPostItemMapper inPostItemMapper, InPostListMapper inPostListMapper, + InListItemMapper inListItemMapper, SysEnterpriseMapper sysEnterpriseMapper, EntPostMapper entPostMapper, EntPostDutyMapper entPostDutyMapper,boolean batch) { this.industryId = industryId; this.inPostMapper = inPostMapper; this.inPostItemMapper = inPostItemMapper; @@ -99,9 +101,32 @@ public class SaveIndustryPostThread implements Runnable { this.entPostMapper = entPostMapper; this.entPostDutyMapper = entPostDutyMapper; this.sysEnterpriseId = sysEnterpriseId; + this.batch = batch; } + 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(), PostListType.LIST_TYPE_IS.getType()); + for (InListItem ili:list) { + addEntPostDuty(ili,i.getUuid(),s.getSysenterpriseid()); + } + } + } + } + finishLastList(); + } public void doing(){ List inPost = inPostMapper.selectByIndustryId(industryId); @@ -113,13 +138,15 @@ public class SaveIndustryPostThread implements Runnable { InPostItem inPostItems = inPostItemMapper.selectByPostId(i.getPublicPostId()); //批量插入企业岗位职责 - List list = inListItemMapper.selectContents(null,inPostItems.getInPostItemId(),null); + List list = inListItemMapper.selectContents(null,inPostItems.getInPostItemId(), PostListType.LIST_TYPE_IS.getType()); for (InListItem ili:list) { addEntPostDuty(ili,i.getUuid(),sysEnterpriseId); } } + finishLastList(); } + private void addEntPostDuty(InListItem ili,String postId,String sysEnterpriseId){ if (entPostDutyList.size() == BATCH_COUNT){ entPostDutyMapper.insertList(entPostDutyList); @@ -137,9 +164,19 @@ public class SaveIndustryPostThread implements Runnable { } } + private void finishLastList(){ + entPostDutyMapper.insertList(entPostDutyList); + entPostDutyList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT); + } + @Override public void run() { - doing(); + if (batch == true){ + batchSave(); + }else { + doing(); + } + } } \ No newline at end of file diff --git a/inventory-ent/src/main/resources/application-dev.yml b/inventory-ent/src/main/resources/application-dev.yml index 4ab94de..fe87281 100644 --- a/inventory-ent/src/main/resources/application-dev.yml +++ b/inventory-ent/src/main/resources/application-dev.yml @@ -3,12 +3,7 @@ server: spring: redis: host: 42.193.40.239 - Auth: redis@rzyc123456 -# 进入哨兵项目-这个端口就不用了,除非是单体 -# port: 6379 - sentinel: - master: mymaster - nodes: 42.193.40.239:26379,42.193.40.239:26380,42.193.40.239:26381 + port: 6378 lettuce: pool: max-active: 8 @@ -16,6 +11,7 @@ spring: min-idle: 0 max-wait: 100 shutdown-timeout: 50000 + Auth: redis@rzyc123456 servlet: multipart: enabled: true diff --git a/inventory-ent/src/main/resources/application-prod.yml b/inventory-ent/src/main/resources/application-prod.yml index f3c50d0..bccf391 100644 --- a/inventory-ent/src/main/resources/application-prod.yml +++ b/inventory-ent/src/main/resources/application-prod.yml @@ -4,12 +4,7 @@ server: spring: redis: host: 42.193.40.239 - Auth: redis@rzyc123456 - # 进入哨兵项目-这个端口就不用了,除非是单体 - # port: 6379 - sentinel: - master: mymaster - nodes: 42.193.40.239:26379,42.193.40.239:26380,42.193.40.239:26381 + port: 6378 lettuce: pool: max-active: 8 @@ -17,6 +12,7 @@ spring: min-idle: 0 max-wait: 100 shutdown-timeout: 50000 + Auth: redis@rzyc123456 servlet: multipart: enabled: true diff --git a/inventory-ent/src/main/resources/application-yun.yml b/inventory-ent/src/main/resources/application-yun.yml index 8aac7e2..359dc20 100644 --- a/inventory-ent/src/main/resources/application-yun.yml +++ b/inventory-ent/src/main/resources/application-yun.yml @@ -16,7 +16,7 @@ spring: min-idle: 0 max-wait: 100 shutdown-timeout: 50000 - password: gzQdzRedis + Auth: gzQdzRedis servlet: multipart: enabled: true diff --git a/inventory-ent/src/main/resources/application.yml b/inventory-ent/src/main/resources/application.yml index e4120de..7a61ab4 100644 --- a/inventory-ent/src/main/resources/application.yml +++ b/inventory-ent/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: profiles: - active: yun #设定打包配置文件 + active: dev #设定打包配置文件 diff --git a/inventory-gov/src/main/resources/application-dev.yml b/inventory-gov/src/main/resources/application-dev.yml index e577c31..6c0494d 100644 --- a/inventory-gov/src/main/resources/application-dev.yml +++ b/inventory-gov/src/main/resources/application-dev.yml @@ -9,12 +9,7 @@ spring: max-request-size: 100MB redis: host: 42.193.40.239 - Auth: redis@rzyc123456 - # 进入哨兵项目-这个端口就不用了,除非是单体 - # port: 6379 - sentinel: - master: mymaster - nodes: 42.193.40.239:26379,42.193.40.239:26380,42.193.40.239:26381 + port: 6378 lettuce: pool: max-active: 8 @@ -22,6 +17,7 @@ spring: min-idle: 0 max-wait: 100 shutdown-timeout: 50000 + Auth: redis@rzyc123456 mvc: view: prefix: classpath:/templates/ @@ -29,6 +25,17 @@ spring: devtools: restart: enabled: true + + + + + + + + + + + thymeleaf: cache: false resources: diff --git a/inventory-gov/src/main/resources/application.yml b/inventory-gov/src/main/resources/application.yml index cb53efc..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: yun #设定打包配置文件 + active: dev #设定打包配置文件