From 491f1359e94087b4e29922f6e58ebc4b15611f58 Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Wed, 6 Nov 2024 15:31:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=A4=84=E7=BD=AE=E4=BC=81?= =?UTF-8?q?=E4=B8=9A=E5=BE=AE=E4=BF=A1=E4=BF=A1=E6=81=AF=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcEmployeesController.java | 9 ++++++ .../zc/business/mapper/DcEmployeesMapper.java | 4 +++ .../business/service/IDcEmployeesService.java | 3 ++ .../service/impl/DcEmployeesServiceImpl.java | 23 ++++++++++++++ .../business/service/impl/MsmServiceImpl.java | 31 +++++++++++++++++-- .../mapper/business/DcEmployeesMapper.xml | 6 ++++ 6 files changed, 73 insertions(+), 3 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcEmployeesController.java b/zc-business/src/main/java/com/zc/business/controller/DcEmployeesController.java index ef66f469..b30e8ef6 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcEmployeesController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcEmployeesController.java @@ -11,11 +11,13 @@ import com.zc.business.enums.UniversalEnum; import com.zc.business.service.IDcEmployeesService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.util.List; +import java.util.Map; /** * 值班人员信息Controller @@ -155,4 +157,11 @@ public class DcEmployeesController extends BaseController public AjaxResult personnelPositions(){ return toAjax(dcEmployeesService.personnelPositions()); } + + @ApiOperation("获取应急机构下的所有人员") + @GetMapping("/getAllEmployees") + public List> getAllEmployees(@ApiParam(value = "桩号", name = "stakeMark", required = true) String stakeMark) + { + return dcEmployeesService.getAllEmployees(stakeMark); + } } diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcEmployeesMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcEmployeesMapper.java index cf646a2b..647022b0 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcEmployeesMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcEmployeesMapper.java @@ -79,4 +79,8 @@ public interface DcEmployeesMapper public Integer updateJobInformation(@Param("employeesId")Long employeesId,@Param("station")Long station); List selectEmployeesByIds(Long[] ids); + + List> selectAllOrganization(); + + List> selectOrganizationEmployees(@Param("organizationId") String organizationId); } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcEmployeesService.java b/zc-business/src/main/java/com/zc/business/service/IDcEmployeesService.java index 2b0e6fc5..7d30bb0d 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcEmployeesService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcEmployeesService.java @@ -71,4 +71,7 @@ public interface IDcEmployeesService public List> selectEmployeesPostAll(); //定时任务,获取值班信息定义人员归属岗位 public int personnelPositions(); + + //获取应急机构下所有人员 + List> getAllEmployees(String stakeMark); } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcEmployeesServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcEmployeesServiceImpl.java index e234eedb..d04a29a2 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcEmployeesServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcEmployeesServiceImpl.java @@ -1,6 +1,7 @@ package com.zc.business.service.impl; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StakeMarkUtils; import com.ruoyi.common.utils.StringUtils; import com.zc.business.domain.DcEmployees; import com.zc.business.enums.UniversalEnum; @@ -160,4 +161,26 @@ public class DcEmployeesServiceImpl implements IDcEmployeesService { } return UniversalEnum.ONE.getNumber(); } + + //获取应急机构下所有人员 + @Override + public List> getAllEmployees(String stakeMark){ + Long stakeMarkNum = StakeMarkUtils.formatMetreLong(stakeMark); + List> organizationList = dcEmployeesMapper.selectAllOrganization(); + if (organizationList != null){ + for (Map organization : organizationList) { + if (StringUtils.isEmpty(organization.get("stakeMark").toString())){ + continue; + } + Long num = StakeMarkUtils.formatMetreLong(organization.get("stakeMark").toString()); + Long difference = Math.abs(stakeMarkNum - num); + organization.put("difference", difference / 1000); + List> employeesList = dcEmployeesMapper.selectOrganizationEmployees(organization.get("id").toString()); + organization.put("employeesList",employeesList); + } + } + + return organizationList; + + } } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/MsmServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/MsmServiceImpl.java index 8ed77809..59853a77 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/MsmServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/MsmServiceImpl.java @@ -12,12 +12,15 @@ import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.spring.SpringUtils; +import com.zc.business.domain.DcEmployees; import com.zc.business.domain.DcEventProcess; import com.zc.business.domain.DcPublishManage; import com.zc.business.enums.UniversalEnum; +import com.zc.business.mapper.DcEmployeesMapper; import com.zc.business.mapper.DcPublishManageMapper; import com.zc.business.service.IMsmService; import com.zc.business.utils.HttpUtil; +import com.zc.business.utils.QYWXUtil; import org.apache.commons.lang3.StringUtils; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; @@ -27,9 +30,7 @@ import org.springframework.transaction.annotation.Transactional; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; +import java.util.*; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executors; import java.util.concurrent.ThreadPoolExecutor; @@ -51,6 +52,10 @@ public class MsmServiceImpl implements IMsmService { private DcEventProcessServiceImpl dcEventProcessService; @Autowired private DcPublishManageMapper dcPublishManageMapper; + @Autowired + private DcEmployeesMapper employeesMapper; + @Autowired + private QYWXUtil qywxUtil; /** * 发送短信 * @@ -280,6 +285,26 @@ public class MsmServiceImpl implements IMsmService { // continue; // } // } + //企业微信推送 + List employees = (List) map.get("employees"); + Long[] ids = employees.stream().mapToLong(Integer::longValue).boxed().toArray(Long[]::new); + List employeesList = employeesMapper.selectEmployeesByIds(ids); + List wxUserIds = new ArrayList<>(); + for (DcEmployees dcEmployees : employeesList) { + if (StringUtils.isNotBlank(dcEmployees.getWxUserId())){ + wxUserIds.add(dcEmployees.getWxUserId()); + } else { + String wxUserId = qywxUtil.getUserIdByMobile(dcEmployees.getContactNumber()); + if (StringUtils.isNotBlank(wxUserId)){ + dcEmployees.setWxUserId(wxUserId); + employeesMapper.updateDcEmployees(dcEmployees); + wxUserIds.add(wxUserId); + } + } + } + qywxUtil.sendMessageByWxUserId(wxUserIds,content); + + DcEventProcess dcEventProcess = new DcEventProcess(); dcEventProcess.setEventId(eventId); dcEventProcess.setSource(UniversalEnum.ONE.getNumber()); diff --git a/zc-business/src/main/resources/mapper/business/DcEmployeesMapper.xml b/zc-business/src/main/resources/mapper/business/DcEmployeesMapper.xml index 87368f53..dd1821ff 100644 --- a/zc-business/src/main/resources/mapper/business/DcEmployeesMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcEmployeesMapper.xml @@ -130,6 +130,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} + + update dc_employees set organization_id=#{station} where employees_id=#{employeesId}