@@ -14,9 +14,9 @@ import java.io.Serializable; | |||
* @author Liuxinxin | |||
* @since 2023-04-17 | |||
*/ | |||
@TableName("expert_gov_business_strip") | |||
@Data | |||
@ApiModel(value = "ExpertGovBusinessStrip对象", description = "") | |||
@TableName("expert_gov_business_strip") | |||
@ApiModel(value = "ExpertGovBusinessStrip对象") | |||
public class ExpertGovBusinessStrip implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
@@ -1,11 +1,16 @@ | |||
package com.ningdatech.pmapi.expert.service; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.ningdatech.pmapi.expert.entity.ExpertGovBusinessStrip; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import java.util.Collection; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* 服务类 | |||
* 服务类 | |||
* </p> | |||
* | |||
* @author Liuxinxin | |||
@@ -13,4 +18,11 @@ import com.baomidou.mybatisplus.extension.service.IService; | |||
*/ | |||
public interface IExpertGovBusinessStripService extends IService<ExpertGovBusinessStrip> { | |||
default List<ExpertGovBusinessStrip> listByUserIds(Collection<Long> userIds) { | |||
LambdaQueryWrapper<ExpertGovBusinessStrip> query = Wrappers | |||
.lambdaQuery(ExpertGovBusinessStrip.class) | |||
.in(ExpertGovBusinessStrip::getExpertUserId, userIds); | |||
return list(query); | |||
} | |||
} |
@@ -0,0 +1,48 @@ | |||
package com.ningdatech.pmapi.gov.controller; | |||
import com.ningdatech.pmapi.gov.manage.BelongOrgManage; | |||
import com.ningdatech.pmapi.gov.model.vo.GovBusinessStripVO; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.validation.annotation.Validated; | |||
import org.springframework.web.bind.annotation.GetMapping; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RequestParam; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* 前端控制器 | |||
* </p> | |||
* | |||
* @author liuxinxin | |||
* @since 2023-04-18 | |||
*/ | |||
@Slf4j | |||
@Validated | |||
@RestController | |||
@RequiredArgsConstructor | |||
@Api(value = "BelongOrgController", tags = "单位所属条线") | |||
@RequestMapping("/api/v1/belong-org") | |||
public class BelongOrgController { | |||
private final BelongOrgManage belongOrgManage; | |||
@GetMapping("/business-strip/list") | |||
@ApiOperation("获取条线列表") | |||
public List<GovBusinessStripVO> getGovBusinessStripList(@RequestParam(value = "businessStripName", required = false) String businessStripName) { | |||
return belongOrgManage.getGovBusinessStripList(businessStripName); | |||
} | |||
@GetMapping("/business-strip/expert/analysis") | |||
@ApiOperation("分析专家数据") | |||
public void analysisExpertOrg() { | |||
belongOrgManage.analysisExpertOrg(); | |||
} | |||
} |
@@ -0,0 +1,44 @@ | |||
package com.ningdatech.pmapi.gov.entity; | |||
import com.baomidou.mybatisplus.annotation.IdType; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import java.io.Serializable; | |||
/** | |||
* <p> | |||
* | |||
* </p> | |||
* | |||
* @author liuxinxin | |||
* @since 2023-04-18 | |||
*/ | |||
@Data | |||
@TableName("belong_org") | |||
@ApiModel(value = "BelongOrg对象") | |||
public class BelongOrg implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
@TableId(type = IdType.AUTO) | |||
private Long id; | |||
@ApiModelProperty("组织code") | |||
private String orgCode; | |||
@ApiModelProperty("组织名称") | |||
private String orgName; | |||
@ApiModelProperty("所属组织code") | |||
private String belongCode; | |||
@ApiModelProperty("所属组织名称") | |||
private String belongName; | |||
@ApiModelProperty("组织类型") | |||
private String orgType; | |||
} |
@@ -0,0 +1,78 @@ | |||
package com.ningdatech.pmapi.gov.entity; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import io.swagger.annotations.ApiModel; | |||
import java.io.Serializable; | |||
/** | |||
* <p> | |||
* | |||
* </p> | |||
* | |||
* @author liuxinxin | |||
* @since 2023-04-13 | |||
*/ | |||
@TableName("gov_business_strip") | |||
@ApiModel(value = "GovBusinessStrip对象", description = "") | |||
public class GovBusinessStrip implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
private Long id; | |||
private String businessStripCode; | |||
private String businessStripName; | |||
private String parentCode; | |||
private String parentName; | |||
public Long getId() { | |||
return id; | |||
} | |||
public void setId(Long id) { | |||
this.id = id; | |||
} | |||
public String getBusinessStripCode() { | |||
return businessStripCode; | |||
} | |||
public void setBusinessStripCode(String businessStripCode) { | |||
this.businessStripCode = businessStripCode; | |||
} | |||
public String getBusinessStripName() { | |||
return businessStripName; | |||
} | |||
public void setBusinessStripName(String businessStripName) { | |||
this.businessStripName = businessStripName; | |||
} | |||
public String getParentCode() { | |||
return parentCode; | |||
} | |||
public void setParentCode(String parentCode) { | |||
this.parentCode = parentCode; | |||
} | |||
public String getParentName() { | |||
return parentName; | |||
} | |||
public void setParentName(String parentName) { | |||
this.parentName = parentName; | |||
} | |||
@Override | |||
public String toString() { | |||
return "GovBusinessStrip{" + | |||
"id=" + id + | |||
", businessStripCode=" + businessStripCode + | |||
", businessStripName=" + businessStripName + | |||
", parentCode=" + parentCode + | |||
", parentName=" + parentName + | |||
"}"; | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
package com.ningdatech.pmapi.gov.enumeration; | |||
/** | |||
* @author liuxinxin | |||
* @date 2023/4/18 下午2:48 | |||
*/ | |||
public enum BelongTypeEnum { | |||
/** | |||
* 组织 | |||
*/ | |||
ORGANIZATION, | |||
/** | |||
* 条线 | |||
*/ | |||
GOV_BUSINESS_STRIP | |||
} |
@@ -0,0 +1,44 @@ | |||
package com.ningdatech.pmapi.gov.helper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.ningdatech.pmapi.expert.entity.ExpertGovBusinessStrip; | |||
import com.ningdatech.pmapi.gov.entity.BelongOrg; | |||
import com.ningdatech.pmapi.gov.service.IBelongOrgService; | |||
import lombok.RequiredArgsConstructor; | |||
import org.apache.commons.collections4.CollectionUtils; | |||
import org.springframework.stereotype.Component; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.stream.Collectors; | |||
/** | |||
* @author liuxinxin | |||
* @date 2023/4/21 下午2:07 | |||
*/ | |||
@Component | |||
@RequiredArgsConstructor | |||
public class GovBusinessStripHelper { | |||
private final IBelongOrgService iBelongOrgService; | |||
public List<ExpertGovBusinessStrip> assemblerBusinessStripInfoList(List<String> businessStripCodeList) { | |||
List<ExpertGovBusinessStrip> businessStripInfoList = new ArrayList<>(); | |||
if (CollectionUtils.isNotEmpty(businessStripCodeList)) { | |||
Map<String, String> codeNameMap = iBelongOrgService.list(Wrappers | |||
.lambdaQuery(BelongOrg.class).in(BelongOrg::getOrgCode, businessStripCodeList)) | |||
.stream().collect(Collectors.toMap(BelongOrg::getOrgCode, BelongOrg::getOrgName)); | |||
businessStripCodeList.forEach(r -> { | |||
ExpertGovBusinessStrip businessStripInfo = new ExpertGovBusinessStrip(); | |||
businessStripInfo.setBusinessStripCode(r); | |||
businessStripInfo.setBusinessStripName(codeNameMap.get(r)); | |||
businessStripInfoList.add(businessStripInfo); | |||
}); | |||
} | |||
return businessStripInfoList; | |||
} | |||
} |
@@ -0,0 +1,219 @@ | |||
package com.ningdatech.pmapi.gov.manage; | |||
import cn.hutool.core.util.StrUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.google.common.collect.Lists; | |||
import com.ningdatech.pmapi.expert.entity.ExpertGovBusinessStrip; | |||
import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo; | |||
import com.ningdatech.pmapi.expert.service.IExpertGovBusinessStripService; | |||
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService; | |||
import com.ningdatech.pmapi.gov.entity.BelongOrg; | |||
import com.ningdatech.pmapi.gov.enumeration.BelongTypeEnum; | |||
import com.ningdatech.pmapi.gov.model.vo.GovBusinessStripVO; | |||
import com.ningdatech.pmapi.gov.service.IBelongOrgService; | |||
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; | |||
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; | |||
import lombok.RequiredArgsConstructor; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.apache.poi.xssf.usermodel.XSSFCell; | |||
import org.apache.poi.xssf.usermodel.XSSFRow; | |||
import org.apache.poi.xssf.usermodel.XSSFSheet; | |||
import org.apache.poi.xssf.usermodel.XSSFWorkbook; | |||
import org.springframework.stereotype.Component; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.io.FileInputStream; | |||
import java.io.IOException; | |||
import java.nio.file.Files; | |||
import java.nio.file.Paths; | |||
import java.util.*; | |||
import java.util.stream.Collectors; | |||
/** | |||
* @author liuxinxin | |||
* @date 2023/4/18 下午2:27 | |||
*/ | |||
@Component | |||
@RequiredArgsConstructor | |||
public class BelongOrgManage { | |||
private final IBelongOrgService iBelongOrgService; | |||
private final IExpertUserFullInfoService expertUserFullInfoService; | |||
private final IDingOrganizationService dingOrganizationService; | |||
private final IExpertGovBusinessStripService expertGovBusinessStripService; | |||
public void generateBusinessStripOrg() { | |||
// 条线Set | |||
Set<String> businessStripSet = new HashSet<>(); | |||
// 组织 Set | |||
Set<String> orgSet = new HashSet<>(); | |||
try { | |||
//创建工作簿对象 | |||
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(Files.newInputStream(Paths.get("/Users/liuxinxin/Desktop/gov_business_strip_inport.xlsx"))); | |||
//获取工作簿下sheet的个数 | |||
int sheetNum = xssfWorkbook.getNumberOfSheets(); | |||
System.out.println("该excel文件中总共有:" + sheetNum + "个sheet"); | |||
//遍历工作簿中的所有数据 | |||
for (int i = 0; i < sheetNum; i++) { | |||
//读取第i个工作表 | |||
System.out.println("读取第" + (i + 1) + "个sheet"); | |||
XSSFSheet sheet = xssfWorkbook.getSheetAt(i); | |||
//获取最后一行的num,即总行数。此处从0开始 | |||
int maxRow = sheet.getLastRowNum(); | |||
// 条线code | |||
// 条线名称 | |||
String businessStripOrgCode = sheet.getRow(1).getCell(0) + ""; | |||
String businessStripOrgName = sheet.getRow(1).getCell(1) + ""; | |||
String uniqKey = businessStripOrgCode + "####" + businessStripOrgName; | |||
businessStripSet.add(uniqKey); | |||
for (int row = 1; row <= maxRow; row++) { | |||
//获取最后单元格num,即总单元格数 ***注意:此处从1开始计数*** | |||
String cell2 = getCellStr(sheet, row, 2); | |||
String cell3 = getCellStr(sheet, row, 3); | |||
if (StringUtils.isNotBlank(cell2) && StringUtils.isNotBlank(cell3)) { | |||
String orgUniqKey = uniqKey + "&&&" + cell2 + "####" + cell3; | |||
orgSet.add(orgUniqKey); | |||
} | |||
String cell4 = getCellStr(sheet, row, 4); | |||
String cell5 = getCellStr(sheet, row, 5); | |||
if (StringUtils.isNotBlank(cell4) && StringUtils.isNotBlank(cell5)) { | |||
String orgUniqKey = uniqKey + "&&&" + cell4 + "####" + cell5; | |||
orgSet.add(orgUniqKey); | |||
} | |||
} | |||
} | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
List<BelongOrg> orgList = orgSet.stream().map(BelongOrgManage::buildBelongOrg).collect(Collectors.toList()); | |||
List<BelongOrg> belongOrgList = businessStripSet.stream().map(BelongOrgManage::buildBusinessStrip).collect(Collectors.toList()); | |||
iBelongOrgService.saveBatch(orgList); | |||
iBelongOrgService.saveBatch(belongOrgList); | |||
} | |||
public static BelongOrg buildBusinessStrip(String businessStripStr) { | |||
String[] split = businessStripStr.split("&&&"); | |||
String busStrip = split[0]; | |||
String[] split1 = busStrip.split("####"); | |||
String belongOrgCode = split1[0]; | |||
String belongOrgName = split1[1]; | |||
BelongOrg belongOrg = new BelongOrg(); | |||
belongOrg.setOrgCode(belongOrgCode); | |||
belongOrg.setOrgName(belongOrgName); | |||
belongOrg.setBelongCode(belongOrgCode); | |||
belongOrg.setBelongName(belongOrgName); | |||
belongOrg.setOrgType(BelongTypeEnum.GOV_BUSINESS_STRIP.name()); | |||
return belongOrg; | |||
} | |||
public static BelongOrg buildBelongOrg(String orgStr) { | |||
String[] split = orgStr.split("&&&"); | |||
String busStrip = split[0]; | |||
String[] split1 = busStrip.split("####"); | |||
String belongOrgCode = split1[0]; | |||
String belongOrgName = split1[1]; | |||
String org = split[1]; | |||
String[] split2 = org.split("####"); | |||
String orgCode = split2[0]; | |||
String orgName = split2[1]; | |||
BelongOrg belongOrg = new BelongOrg(); | |||
belongOrg.setOrgCode(orgCode); | |||
belongOrg.setOrgName(orgName); | |||
belongOrg.setBelongCode(belongOrgCode); | |||
belongOrg.setBelongName(belongOrgName); | |||
belongOrg.setOrgType(BelongTypeEnum.ORGANIZATION.name()); | |||
return belongOrg; | |||
} | |||
public static String getCellStr(XSSFSheet sheet, int row, int col) { | |||
if (Objects.isNull(sheet)) { | |||
return null; | |||
} | |||
XSSFRow row1 = sheet.getRow(row); | |||
if (Objects.isNull(row1)) { | |||
return null; | |||
} | |||
XSSFCell cell = row1.getCell(col); | |||
if (Objects.isNull(cell)) { | |||
return null; | |||
} | |||
return cell + "".trim(); | |||
} | |||
public List<GovBusinessStripVO> getGovBusinessStripList(String businessStripName) { | |||
LambdaQueryWrapper<BelongOrg> query = Wrappers.lambdaQuery(BelongOrg.class) | |||
.like(StrUtil.isNotBlank(businessStripName), BelongOrg::getBelongName, businessStripName) | |||
.eq(BelongOrg::getOrgType, BelongTypeEnum.GOV_BUSINESS_STRIP.name()); | |||
List<BelongOrg> belongOrgs = iBelongOrgService.list(query); | |||
return belongOrgs.stream().map(r -> { | |||
GovBusinessStripVO govBusinessStripVO = new GovBusinessStripVO(); | |||
govBusinessStripVO.setBusinessStripCode(r.getOrgCode()); | |||
govBusinessStripVO.setBusinessStripName(r.getOrgName()); | |||
return govBusinessStripVO; | |||
}).collect(Collectors.toList()); | |||
} | |||
@Transactional(rollbackFor = Exception.class) | |||
public void analysisExpertOrg() { | |||
List<ExpertUserFullInfo> expertUserFullInfoList = expertUserFullInfoService.list(); | |||
for (ExpertUserFullInfo userFullInfo : expertUserFullInfoList) { | |||
String company = userFullInfo.getCompany(); | |||
if (StringUtils.isNotBlank(company)) { | |||
// 获取专家信息 | |||
List<DingOrganization> dingOrganizationList = dingOrganizationService | |||
.list(Wrappers.lambdaQuery(DingOrganization.class) | |||
.eq(DingOrganization::getOrganizationName, company.trim())); | |||
if (CollectionUtils.isNotEmpty(dingOrganizationList)) { | |||
// 获取专家组织code | |||
DingOrganization dingOrganization = dingOrganizationList.get(0); | |||
String organizationCode = dingOrganization.getOrganizationCode(); | |||
List<BelongOrg> belongOrgList = iBelongOrgService | |||
.list(Wrappers.lambdaQuery(BelongOrg.class) | |||
.eq(BelongOrg::getOrgCode, organizationCode.trim())); | |||
if (CollectionUtils.isNotEmpty(belongOrgList)) { | |||
// 获取专家条线code | |||
Set<String> belongOrgSet = new HashSet<>(); | |||
List<BelongOrg> saveList = new ArrayList<>(); | |||
for (BelongOrg belongOrg : belongOrgList) { | |||
if (belongOrgSet.add(belongOrg.getBelongCode())) { | |||
saveList.add(belongOrg); | |||
} | |||
} | |||
expertGovBusinessStripService.remove(Wrappers.lambdaQuery(ExpertGovBusinessStrip.class) | |||
.eq(ExpertGovBusinessStrip::getExpertUserId, userFullInfo.getUserId())); | |||
List<ExpertGovBusinessStrip> expertBusinessStripSaveRecordList = saveList.stream().map(r -> { | |||
ExpertGovBusinessStrip expertBusinessStrip = new ExpertGovBusinessStrip(); | |||
expertBusinessStrip.setExpertUserId(userFullInfo.getUserId()); | |||
expertBusinessStrip.setBusinessStripCode(r.getBelongCode()); | |||
expertBusinessStrip.setBusinessStripName(r.getBelongName()); | |||
return expertBusinessStrip; | |||
}).collect(Collectors.toList()); | |||
expertGovBusinessStripService.saveBatch(expertBusinessStripSaveRecordList); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.ningdatech.pmapi.gov.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.ningdatech.pmapi.gov.entity.BelongOrg; | |||
/** | |||
* <p> | |||
* Mapper 接口 | |||
* </p> | |||
* | |||
* @author liuxinxin | |||
* @since 2023-04-18 | |||
*/ | |||
public interface BelongOrgMapper extends BaseMapper<BelongOrg> { | |||
} |
@@ -0,0 +1,21 @@ | |||
package com.ningdatech.pmapi.gov.model.vo; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
/** | |||
* @author Liuxinxin | |||
* @since 2023-03-08 | |||
*/ | |||
@Data | |||
@ApiModel(value = "条线VO", description = "") | |||
public class GovBusinessStripVO { | |||
@ApiModelProperty("条线code") | |||
private String businessStripCode; | |||
@ApiModelProperty("条线名称") | |||
private String businessStripName; | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.ningdatech.pmapi.gov.service; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.ningdatech.pmapi.gov.entity.BelongOrg; | |||
/** | |||
* <p> | |||
* 服务类 | |||
* </p> | |||
* | |||
* @author liuxinxin | |||
* @since 2023-04-18 | |||
*/ | |||
public interface IBelongOrgService extends IService<BelongOrg> { | |||
} |
@@ -0,0 +1,20 @@ | |||
package com.ningdatech.pmapi.gov.service.impl; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.ningdatech.pmapi.gov.entity.BelongOrg; | |||
import com.ningdatech.pmapi.gov.mapper.BelongOrgMapper; | |||
import com.ningdatech.pmapi.gov.service.IBelongOrgService; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* <p> | |||
* 服务实现类 | |||
* </p> | |||
* | |||
* @author liuxinxin | |||
* @since 2023-04-18 | |||
*/ | |||
@Service | |||
public class BelongOrgServiceImpl extends ServiceImpl<BelongOrgMapper, BelongOrg> implements IBelongOrgService { | |||
} |
@@ -39,6 +39,9 @@ public class ExpertInviteAvoidRule implements Serializable { | |||
@ApiModelProperty("回避条线ID") | |||
private String avoidOrgIds; | |||
@ApiModelProperty("回避类型") | |||
private Integer avoidType; | |||
@ApiModelProperty("每周参与次数") | |||
private Integer weekInviteCount; | |||
@@ -4,7 +4,6 @@ import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotEmpty; | |||
import java.util.List; | |||
/** | |||
@@ -19,19 +18,20 @@ import java.util.List; | |||
@ApiModel("回避信息") | |||
public class AvoidRuleDTO { | |||
@ApiModelProperty("回避类型:1 回避同单位、2 回避同条线、3 不回避") | |||
private Integer avoidType; | |||
@ApiModelProperty("回避单位") | |||
@NotEmpty(message = "回避单位不能为空", groups = {AbstractInviteRule.RuleSave.class}) | |||
private List<String> avoidUnitIdList; | |||
@ApiModelProperty("回避条线") | |||
@NotEmpty(message = "回避条线不能为空", groups = {AbstractInviteRule.RuleSave.class}) | |||
private List<String> avoidOrgIdList; | |||
@ApiModelProperty("每周邀请次数") | |||
private Integer weekInviteCount; | |||
@ApiModelProperty("回避专家") | |||
@NotEmpty(message = "回避专家不能为空", groups = {AbstractInviteRule.RuleSave.class}) | |||
private List<Long> expertIds; | |||
} |
@@ -0,0 +1,35 @@ | |||
package com.ningdatech.pmapi.meeting.entity.enumeration; | |||
import com.ningdatech.basic.exception.BizException; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Getter; | |||
import java.util.Arrays; | |||
/** | |||
* <p> | |||
* AvoidTypeEnum | |||
* </p> | |||
* | |||
* @author WendyYang | |||
* @since 2023/8/17 | |||
**/ | |||
@Getter | |||
@AllArgsConstructor | |||
public enum AvoidTypeEnum { | |||
CURR_UNIT(1, "同单位"), | |||
CURR_STRIP(2, "同条线"), | |||
NONE(3, "不回避"); | |||
private final Integer code; | |||
private final String remark; | |||
public static AvoidTypeEnum getByCode(int code) { | |||
return Arrays.stream(values()) | |||
.filter(w -> w.getCode().equals(code)) | |||
.findFirst() | |||
.orElseThrow(() -> BizException.wrap("回避类型无效")); | |||
} | |||
} |
@@ -1,15 +1,14 @@ | |||
package com.ningdatech.pmapi.meeting.helper; | |||
import cn.hutool.core.util.RandomUtil; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.ningdatech.pmapi.expert.entity.ExpertGovBusinessStrip; | |||
import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo; | |||
import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; | |||
import org.apache.commons.collections4.MapUtils; | |||
import org.apache.commons.lang3.RandomUtils; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.*; | |||
import java.util.stream.Collectors; | |||
/** | |||
@@ -74,6 +73,77 @@ public class ExpertRandomInviteAlgorithm { | |||
} | |||
} | |||
public static List<ExpertUserFullInfo> inviteGroupByStrip(Map<String, List<ExpertGovBusinessStrip>> expertStripGroup, | |||
List<ExpertUserFullInfo> userFullInfoList, | |||
List<List<MeetingExpert>> expertsByRecentMeeting, | |||
Integer count) { | |||
if (MapUtils.isEmpty(expertStripGroup)) { | |||
return Collections.emptyList(); | |||
} | |||
Map<Long, ExpertUserFullInfo> userMap = CollUtils.listToMap(userFullInfoList, ExpertUserFullInfo::getUserId); | |||
if (expertsByRecentMeeting.isEmpty()) { | |||
return expertStripGroup.values().stream() | |||
.map(w -> { | |||
ExpertUserFullInfo euf; | |||
while (true) { | |||
ExpertGovBusinessStrip ele = RandomUtil.randomEle(w); | |||
euf = userMap.remove(ele.getExpertUserId()); | |||
if (euf != null || w.isEmpty() || userMap.isEmpty()) { | |||
break; | |||
} | |||
w.remove(ele); | |||
} | |||
return euf; | |||
}).filter(Objects::nonNull) | |||
.limit(count) | |||
.collect(Collectors.toList()); | |||
} else { | |||
List<ExpertUserFullInfo> lockedUsers = new ArrayList<>(); | |||
List<String> strips = new ArrayList<>(expertStripGroup.keySet()); | |||
for (int i = 0; i < count; i++) { | |||
String strip = strips.get(RandomUtils.nextInt(0, strips.size())); | |||
List<ExpertGovBusinessStrip> expertsByStrip = expertStripGroup.get(strip); | |||
for (int j = 0; j < expertsByRecentMeeting.size(); j++) { | |||
List<MeetingExpert> experts = expertsByRecentMeeting.get(j); | |||
List<ExpertUserFullInfo> notInvitedUsers = expertsByStrip.stream() | |||
.map(w -> userMap.get(w.getExpertUserId())) | |||
.filter(w -> w != null && expertMatchNone(experts, w)) | |||
.collect(Collectors.toList()); | |||
if (!notInvitedUsers.isEmpty()) { | |||
ExpertUserFullInfo usf = RandomUtil.randomEle(notInvitedUsers); | |||
// 防止一个专家多条线 | |||
userMap.remove(usf.getUserId()); | |||
lockedUsers.add(usf); | |||
break; | |||
} else if (j == (expertsByRecentMeeting.size() - 1)) { | |||
ExpertUserFullInfo euf; | |||
ExpertGovBusinessStrip egs = RandomUtil.randomEle(expertsByStrip); | |||
while (true) { | |||
euf = userMap.remove(egs.getExpertUserId()); | |||
if (euf != null || expertsByStrip.isEmpty() || userMap.isEmpty()) { | |||
break; | |||
} | |||
expertsByStrip.remove(egs); | |||
} | |||
if (euf != null) { | |||
lockedUsers.add(euf); | |||
} | |||
} | |||
if (userMap.isEmpty()) { | |||
return lockedUsers; | |||
} | |||
} | |||
if (lockedUsers.size() < count) { | |||
strips.remove(strip); | |||
if (strips.isEmpty()) { | |||
break; | |||
} | |||
} | |||
} | |||
return lockedUsers; | |||
} | |||
} | |||
/** | |||
* 随机抽取专家 | |||
* | |||
@@ -103,7 +173,7 @@ public class ExpertRandomInviteAlgorithm { | |||
userFullInfos.removeAll(notInvitedUsers); | |||
} | |||
} | |||
if (userFullInfos.size() == 0) { | |||
if (userFullInfos.isEmpty()) { | |||
return result; | |||
} | |||
int restCnt = Math.min(count - result.size(), userFullInfos.size()); | |||
@@ -8,8 +8,10 @@ import com.ningdatech.basic.util.CollUtils; | |||
import com.ningdatech.pmapi.common.util.BizUtils; | |||
import com.ningdatech.pmapi.expert.constant.ExpertAccountStatusEnum; | |||
import com.ningdatech.pmapi.expert.entity.ExpertAvoidCompany; | |||
import com.ningdatech.pmapi.expert.entity.ExpertGovBusinessStrip; | |||
import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo; | |||
import com.ningdatech.pmapi.expert.service.IExpertAvoidCompanyService; | |||
import com.ningdatech.pmapi.expert.service.IExpertGovBusinessStripService; | |||
import com.ningdatech.pmapi.expert.service.IExpertIntentionWorkRegionService; | |||
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService; | |||
import com.ningdatech.pmapi.meeting.builder.ExpertInviteBuilder; | |||
@@ -17,8 +19,10 @@ import com.ningdatech.pmapi.meeting.entity.domain.ExpertInviteRule; | |||
import com.ningdatech.pmapi.meeting.entity.domain.Meeting; | |||
import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; | |||
import com.ningdatech.pmapi.meeting.entity.dto.*; | |||
import com.ningdatech.pmapi.meeting.entity.enumeration.AvoidTypeEnum; | |||
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; | |||
import com.ningdatech.pmapi.meeting.helper.ExpertInviteHelper; | |||
import com.ningdatech.pmapi.meeting.helper.ExpertRandomInviteAlgorithm; | |||
import com.ningdatech.pmapi.meeting.helper.MeetingCallOrMsgHelper; | |||
import com.ningdatech.pmapi.meeting.service.IExpertInviteRuleService; | |||
import com.ningdatech.pmapi.meeting.service.IMeetingExpertService; | |||
@@ -41,7 +45,7 @@ import java.util.stream.Collectors; | |||
import static com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum.*; | |||
import static com.ningdatech.pmapi.meeting.helper.ExpertInviteHelper.getExpertInviteRule; | |||
import static com.ningdatech.pmapi.meeting.helper.ExpertRandomInviteAlgorithm.inviteGroupByCompany; | |||
import static com.ningdatech.pmapi.meeting.helper.ExpertRandomInviteAlgorithm.*; | |||
/** | |||
* <p> | |||
@@ -66,6 +70,7 @@ public class ExpertInviteManage { | |||
private final IMeetingService meetingService; | |||
private final IExpertAvoidCompanyService expertAvoidCompanyService; | |||
private final MeetingCallOrMsgHelper meetingCallOrMsgHelper; | |||
private final IExpertGovBusinessStripService expertGovBusinessStripService; | |||
@Value("#{randomInviteProperties.recentMeetingCount}") | |||
private Integer recentMeetingCount; | |||
@@ -364,10 +369,29 @@ public class ExpertInviteManage { | |||
if (userInfoList.isEmpty()) { | |||
return result; | |||
} | |||
Map<String, List<ExpertUserFullInfo>> userGroupByUnit = CollUtils.group(userInfoList, ExpertUserFullInfo::getCompanyUniqCode); | |||
result.setTotal(userGroupByUnit.size()); | |||
result.setExperts(inviteGroupByCompany(userGroupByUnit, expertsByRecentMeeting(), randomRule.getCount())); | |||
AvoidTypeEnum avoidType = avoidRule.getAvoidType() == null ? AvoidTypeEnum.CURR_UNIT : AvoidTypeEnum.getByCode(avoidRule.getAvoidType()); | |||
switch (avoidType) { | |||
case NONE: | |||
result.setExperts(inviteWithoutCompany(userInfoList, expertsByRecentMeeting(), randomRule.getCount())); | |||
result.setTotal(userInfoList.size()); | |||
break; | |||
case CURR_UNIT: | |||
Map<String, List<ExpertUserFullInfo>> unitGroup = CollUtils.group(userInfoList, ExpertUserFullInfo::getCompanyUniqCode); | |||
result.setExperts(inviteGroupByCompany(unitGroup, expertsByRecentMeeting(), randomRule.getCount())); | |||
result.setTotal(unitGroup.size()); | |||
break; | |||
case CURR_STRIP: | |||
List<Long> userIds = CollUtils.fieldList(userInfoList, ExpertUserFullInfo::getUserId); | |||
List<ExpertGovBusinessStrip> expertStrips = expertGovBusinessStripService.listByUserIds(userIds); | |||
if (!expertStrips.isEmpty()) { | |||
Map<String, List<ExpertGovBusinessStrip>> stripGroup = CollUtils.group(expertStrips, ExpertGovBusinessStrip::getBusinessStripCode); | |||
result.setExperts(inviteGroupByStrip(stripGroup, userInfoList, expertsByRecentMeeting(), randomRule.getCount())); | |||
result.setTotal(stripGroup.size()); | |||
} else { | |||
result.setTotal(0); | |||
} | |||
break; | |||
} | |||
return result; | |||
} | |||
@@ -525,7 +549,7 @@ public class ExpertInviteManage { | |||
AvoidRuleDTO avoidRule) { | |||
List<MeetingExpert> expertInserts = new ArrayList<>(); | |||
// 处理随机抽取规则 | |||
if (CollectionUtils.isNotEmpty(randomRules)) { | |||
if (CollUtil.isNotEmpty(randomRules)) { | |||
List<ExpertInviteRule> randoms = new ArrayList<>(); | |||
List<ExpertChooseDTO> expertsByRandom = new ArrayList<>(); | |||
List<Long> chooseExpertIds = new ArrayList<>(); | |||
@@ -253,6 +253,7 @@ public class MeetingManage { | |||
avoidRule.setAvoidOrgIds(CollUtils.joinByComma(avoidInfo.getAvoidOrgIdList())); | |||
avoidRule.setAvoidUnitIds(CollUtils.joinByComma(avoidInfo.getAvoidUnitIdList())); | |||
avoidRule.setAvoidExpertIds(CollUtils.joinByComma(avoidInfo.getExpertIds())); | |||
avoidRule.setAvoidType(avoidInfo.getAvoidType()); | |||
inviteAvoidRuleService.save(avoidRule); | |||
} else { | |||
// 指定邀请 | |||
@@ -1,13 +1,23 @@ | |||
package com.ningdatech.pmapi.org; | |||
import cn.hutool.core.collection.CollUtil; | |||
import cn.hutool.core.map.MapUtil; | |||
import cn.hutool.core.util.StrUtil; | |||
import cn.hutool.extra.spring.SpringUtil; | |||
import cn.hutool.poi.excel.ExcelReader; | |||
import cn.hutool.poi.excel.ExcelUtil; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.ningdatech.basic.util.SpringUtils; | |||
import com.ningdatech.pmapi.AppTests; | |||
import com.ningdatech.pmapi.gov.entity.BelongOrg; | |||
import com.ningdatech.pmapi.gov.enumeration.BelongTypeEnum; | |||
import com.ningdatech.pmapi.gov.service.IBelongOrgService; | |||
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; | |||
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; | |||
import org.junit.Test; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import java.util.List; | |||
import java.util.*; | |||
/** | |||
* @Classname RegionTest | |||
@@ -19,16 +29,18 @@ public class OrgTest extends AppTests { | |||
@Autowired | |||
private IDingOrganizationService organizationService; | |||
@Autowired | |||
private IBelongOrgService belongOrgService; | |||
@Test | |||
public void test(){ | |||
public void test() { | |||
List<DingOrganization> orgs = organizationService.list(Wrappers.lambdaQuery(DingOrganization.class) | |||
.eq(DingOrganization::getDivisionCode, "331199")); | |||
for(DingOrganization org : orgs){ | |||
for (DingOrganization org : orgs) { | |||
List<DingOrganization> inners = organizationService.list(Wrappers.lambdaQuery(DingOrganization.class) | |||
.eq(DingOrganization::getParentCode, org.getOrganizationCode())); | |||
for(DingOrganization inner : inners){ | |||
for (DingOrganization inner : inners) { | |||
mergeRegionCode(inner); | |||
} | |||
} | |||
@@ -40,12 +52,62 @@ public class OrgTest extends AppTests { | |||
List<DingOrganization> is = organizationService.list(Wrappers.lambdaQuery(DingOrganization.class) | |||
.eq(DingOrganization::getParentCode, inner.getOrganizationCode())); | |||
if(CollUtil.isEmpty(is)){ | |||
if (CollUtil.isEmpty(is)) { | |||
return; | |||
} | |||
for(DingOrganization i : is){ | |||
for (DingOrganization i : is) { | |||
mergeRegionCode(i); | |||
} | |||
} | |||
@Test | |||
public void businessStrip() { | |||
String path = "/Users/wendy/Desktop/省市县条线单位梳理202303016.xlsx"; | |||
ExcelReader reader = ExcelUtil.getReader(path); | |||
Set<String> orgCodes = new HashSet<>(); | |||
List<BelongOrg> belongOrgs = new ArrayList<>(); | |||
for (int i = 0; i < reader.getSheetCount(); i++) { | |||
reader.setSheet(i); | |||
List<Map<String, Object>> maps = reader.readAll(); | |||
for (Map<String, Object> map : maps) { | |||
String cityName = MapUtil.getStr(map, "市级组织名称"); | |||
if (cityName == null || !cityName.contains("丽水")) { | |||
continue; | |||
} | |||
String cityCode = MapUtil.getStr(map, "市级组织机构代码"); | |||
if (StrUtil.isBlank(cityCode)) { | |||
continue; | |||
} | |||
String countyName = MapUtil.getStr(map, "区县组织名称"); | |||
if (StrUtil.isBlank(countyName)) { | |||
continue; | |||
} | |||
String countyCode = MapUtil.getStr(map, "区县组织机构代码"); | |||
if (StrUtil.isBlank(countyCode)) { | |||
continue; | |||
} | |||
System.out.printf("市级:%s -> %s 区县:%s -> %s\n", cityName, cityCode, countyName, countyCode); | |||
BelongOrg county = new BelongOrg(); | |||
county.setBelongCode(cityCode); | |||
county.setBelongName(cityName); | |||
county.setOrgCode(countyCode); | |||
county.setOrgName(countyName); | |||
county.setOrgType(BelongTypeEnum.ORGANIZATION.name()); | |||
belongOrgs.add(county); | |||
if (!orgCodes.add(cityCode)) { | |||
continue; | |||
} | |||
BelongOrg city = new BelongOrg(); | |||
city.setBelongCode(cityCode); | |||
city.setBelongName(cityName); | |||
city.setOrgCode(cityCode); | |||
city.setOrgName(cityName); | |||
city.setOrgType(BelongTypeEnum.GOV_BUSINESS_STRIP.name()); | |||
belongOrgs.add(city); | |||
} | |||
belongOrgs.forEach(System.out::println); | |||
} | |||
belongOrgService.saveBatch(belongOrgs); | |||
} | |||
} |
@@ -182,7 +182,7 @@ organization: | |||
- GO_ff70e47bae684fdba0d64f4acab85661 | |||
yxt: | |||
# wsdl-url: http://115.239.137.23:9501/ws/v1?wsdl | |||
# wsdl-url: http://115.239.137.23:9501/ws/v1?wsdl | |||
wsdl-url: classpath:/wsdl.xml | |||
#账号 | |||
user-code: hzndkj | |||
@@ -194,7 +194,7 @@ yxt: | |||
#省局联审 请求信息 | |||
provincial: | |||
# host: http://zj.ningdatech.com/prometheus-zhejiang_foreign | |||
# host: http://zj.ningdatech.com/prometheus-zhejiang_foreign | |||
host: http://223.4.72.75/prometheus-zhejiang_foreign | |||
pushUrl: /api/v1/foreign/importantPro | |||
detailUrl: /api/v1/foreign/importantProView | |||
@@ -208,7 +208,7 @@ irs: | |||
is-search-app: false | |||
digital-resource-indicators: | |||
url: https://interface.zjzwfw.gov.cn/gateway/api/proxy/001003001029/dataSharing/99E2bic31KdXzaa7.htm | |||
interfaceName: 99E2bic31KdXzaa7 | |||
interface-name: 99E2bic31KdXzaa7 | |||
app-key: A331101453557202109017383 | |||
app-secret: 496f0f2a19994f76b4fd9dae087366c7 | |||
seal-platform: | |||
@@ -253,5 +253,6 @@ hostname: iZbp13nwyvib53j4j1p2xoZ | |||
login: | |||
phone-verify-code: | |||
skip: true | |||
url: http://lspm.ningdatech.com/login | |||