Browse Source

消息 成员同步

zyh
小久哥 3 years ago
parent
commit
8d89747fe4
  1. 9
      yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/CpUser/CpUserServiceImpl.java
  2. 42
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgAspect.java
  3. 4
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/StatisticalController.java

9
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/CpUser/CpUserServiceImpl.java

@ -110,7 +110,13 @@ public class CpUserServiceImpl extends ServiceImpl<CpUserMapper,CpUserDO> implem
public void cpUserSync() throws WxErrorException { public void cpUserSync() throws WxErrorException {
WxCpConfigStorage config = wxCpService.getWxCpConfigStorage(); WxCpConfigStorage config = wxCpService.getWxCpConfigStorage();
List<WxCpDepart> departList = wxCpService.getDepartmentService().list(null); List<WxCpDepart> departList = wxCpService.getDepartmentService().list(null);
List<WxCpUser> userList = wxCpService.getUserService().listByDepartment(1L, true, 0);
//根据部门id获取部门成员信息
//6 旭清回鄉生態農業發展公司
//35 回鄉信息技术公司
List<WxCpUser> userList = wxCpService.getUserService().listByDepartment(6L, true, 0);
userList.addAll(wxCpService.getUserService().listByDepartment(35L, true, 0));
List<CpUserDO> rs = CpUserConvert.INSTANCE.convertListFromWxApi(userList); List<CpUserDO> rs = CpUserConvert.INSTANCE.convertListFromWxApi(userList);
@ -120,7 +126,6 @@ public class CpUserServiceImpl extends ServiceImpl<CpUserMapper,CpUserDO> implem
List<String> nowUsersIds = nowUsers.stream().map(CpUserDO::getUserId).collect(Collectors.toList()); List<String> nowUsersIds = nowUsers.stream().map(CpUserDO::getUserId).collect(Collectors.toList());
rs.removeIf(cpUserDO -> nowUsersIds.contains(cpUserDO.getUserId())); rs.removeIf(cpUserDO -> nowUsersIds.contains(cpUserDO.getUserId()));
this.saveBatch(rs); this.saveBatch(rs);
// 已经离职的员工 设置删除 // 已经离职的员工 设置删除

42
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgAspect.java

@ -108,20 +108,10 @@ public class FarmMsgAspect {
AdminUserDO adminUser = adminUserMapper.selectOne(AdminUserDO::getId, getLoginUserId()); AdminUserDO adminUser = adminUserMapper.selectOne(AdminUserDO::getId, getLoginUserId());
CpUserDO user = cpUserMapper.selectOne(CpUserDO::getUserId, adminUser.getCpUserId()); CpUserDO user = cpUserMapper.selectOne(CpUserDO::getUserId, adminUser.getCpUserId());
StringBuilder description = new StringBuilder() // if (!toUserStr.contains("WeiLaiKeQi")){
.append(user.getName()) // return object;
.append(" ") // }
.append(farmMsgDTO.getOperation().getDesc())
.append(farmMsgDTO.getType().getDesc())
.append(":")
.append(ObjectUtil.isEmpty(farmMsgDTO.getMsg()) ? farmMsgDTO.getTitle() : farmMsgDTO.getMsg())
.append("(其中有你)");
if (!toUserStr.contains("WeiLaiKeQi")){
return object;
}
if (!farmMsgDTO.getNoSendMsg()){ if (!farmMsgDTO.getNoSendMsg()){
//企业微信内部发送信息
//this.sendCpMsg(description.toString(), toUserStr);
//企业微信小程序通知消息 //企业微信小程序通知消息
this.sendMiniMsg(user, farmMsgDTO, toUserStr); this.sendMiniMsg(user, farmMsgDTO, toUserStr);
} }
@ -141,31 +131,6 @@ public class FarmMsgAspect {
return object; return object;
} }
public void sendCpMsg(String desc, String userStr) throws Throwable{
// 构造一个企业推送消息
WxCpMessage message = new WxCpMessage();
// 发企业微信
WxCpMessageService wxCpMessageService = wxCpService.getMessageService();
//消息类型 必填 此处固定为 文本卡片
message.setMsgType("textcard");
//企业应用id 必填
message.setAgentId(wxCpService.getWxCpConfigStorage().getAgentId());
//消息标题 必填
message.setTitle("回乡农场通知");
//消息描述 必填
message.setDescription(desc);
//点击后跳转链接 必填
message.setUrl("https://www.baidu.com");
//接受消息成员 选填
message.setToUser(userStr);
log.info("企业微信消息发送内容:{}", message);
WxCpMessageSendResult result = wxCpMessageService.send(message);
log.info("企业微信消息发送结果:{}",result);
}
//发送小程序通知消息 //发送小程序通知消息
public void sendMiniMsg(CpUserDO createUser, FarmMsgDTO farmMsgDTO, String toUserStr) throws WxErrorException { public void sendMiniMsg(CpUserDO createUser, FarmMsgDTO farmMsgDTO, String toUserStr) throws WxErrorException {
// 发小程序 // 发小程序
@ -181,6 +146,7 @@ public class FarmMsgAspect {
message.setAppId(appid); message.setAppId(appid);
message.setTitle(farmMsgDTO.getType().getDesc() + farmMsgDTO.getOperation().getDesc() + "通知"); message.setTitle(farmMsgDTO.getType().getDesc() + farmMsgDTO.getOperation().getDesc() + "通知");
message.setDescription(LocalDateTimeUtil.formatNormal(LocalDateTime.now())); message.setDescription(LocalDateTimeUtil.formatNormal(LocalDateTime.now()));
message.setPage(farmMsgDTO.getType().equals(FarmMsgTypeEnum.PROJECT) ? "pages/project/index" : "pages/task/index");
Map<String, String> map2 = new HashMap<>(); Map<String, String> map2 = new HashMap<>();
map2.put("发起人", createUser.getName()); map2.put("发起人", createUser.getName());

4
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/StatisticalController.java

@ -115,12 +115,12 @@ public class StatisticalController {
if (taskDO.getCropId().equals(cropDO.getId())){ if (taskDO.getCropId().equals(cropDO.getId())){
if (cropMap.containsKey(cropDO.getId())){ if (cropMap.containsKey(cropDO.getId())){
CakeSeries cakeSeries = cropMap.get(cropDO.getId()); CakeSeries cakeSeries = cropMap.get(cropDO.getId());
cakeSeries.setValue(cakeSeries.getValue() + taskDO.getCropNum()); cakeSeries.setValue(cakeSeries.getValue() + (taskDO.getCropNum() == null ? 0 : taskDO.getCropNum()));
}else{ }else{
CakeSeries cakeSeries = CakeSeries.builder() CakeSeries cakeSeries = CakeSeries.builder()
.name(cropDO.getName()) .name(cropDO.getName())
.value(taskDO.getCropNum()) .value(taskDO.getCropNum() == null ? 0 : taskDO.getCropNum())
.labelText("不知道说啥") .labelText("不知道说啥")
.build(); .build();
cropMap.put(cropDO.getId(), cakeSeries); cropMap.put(cropDO.getId(), cakeSeries);

Loading…
Cancel
Save