Commit 1d593802 authored by suhuiguang's avatar suhuiguang

1.96333 提交接口人员信息调用平台查询人员实现

parent 7ad3f568
...@@ -103,6 +103,8 @@ public class ControllerAop { ...@@ -103,6 +103,8 @@ public class ControllerAop {
urls.add("^/tcm/flc-unit-info/hasExistUser/[A-Za-z0-9_-]+"); urls.add("^/tcm/flc-unit-info/hasExistUser/[A-Za-z0-9_-]+");
urls.add("/tcm/reg-unit-info/save"); urls.add("/tcm/reg-unit-info/save");
urls.add("/ymt/equipment-category/getFormRecordById"); urls.add("/ymt/equipment-category/getFormRecordById");
urls.add("/elevator/alert-called/getWorkOderNumber");
urls.add("/elevator/alert-called/save");
// 获取请求路径 // 获取请求路径
for (String uri : urls) { for (String uri : urls) {
Pattern p = Pattern.compile(uri); Pattern p = Pattern.compile(uri);
......
...@@ -93,4 +93,10 @@ public interface IAlertCalledService { ...@@ -93,4 +93,10 @@ public interface IAlertCalledService {
List<AlertPaperInfoDto> getEquipmentHistory(List<String> useRegionCode, String equipmentClassCode, Integer current, Integer pageNum, String equipmentCode); List<AlertPaperInfoDto> getEquipmentHistory(List<String> useRegionCode, String equipmentClassCode, Integer current, Integer pageNum, String equipmentCode);
Integer getEquipmentHistoryCount(List<String> useRegionCode, String equipmentClassCode, String equipmentCode); Integer getEquipmentHistoryCount(List<String> useRegionCode, String equipmentClassCode, String equipmentCode);
/**
* 生成工单号
* @return
*/
String nextId();
} }
package com.yeejoin.amos.boot.module.elevator.biz.config;
import lombok.extern.slf4j.Slf4j;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@Slf4j
public class RedissonManager {
/**
* 集群环境使用-节点信息
*/
@Value("${spring.redis.cluster.nodes:default}")
private String clusterNodes;
/**
* 公共-密码
*/
@Value("${spring.redis.password}")
private String password;
/**
* 单机环境使用
*/
@Value("${spring.redis.host:default}")
private String host;
/**
* 单机环境使用
*/
@Value("${spring.redis.port:default}")
private String port;
@Bean
@ConditionalOnProperty(name = "spring.redis.mode", havingValue = "cluster")
public RedissonClient redissonClient() {
Config config = new Config();
config.useClusterServers()
.addNodeAddress(clusterNodes.split(","))
.setPassword(password);
return Redisson.create(config);
}
@Bean
@ConditionalOnProperty(name = "spring.redis.mode", havingValue = "singleton", matchIfMissing = true)
public RedissonClient redissonSingletonClient() {
// 单机打包使用
Config config = new Config();
config.useSingleServer().setAddress(host + ":" + port).setPassword(password);
return Redisson.create(config);
}
}
...@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.SystemClock;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
...@@ -18,11 +17,11 @@ import com.yeejoin.amos.boot.module.elevator.biz.service.impl.*; ...@@ -18,11 +17,11 @@ import com.yeejoin.amos.boot.module.elevator.biz.service.impl.*;
import com.yeejoin.amos.boot.module.elevator.api.dto.*; import com.yeejoin.amos.boot.module.elevator.api.dto.*;
import com.yeejoin.amos.boot.module.elevator.api.entity.*; import com.yeejoin.amos.boot.module.elevator.api.entity.*;
import com.yeejoin.amos.boot.module.elevator.api.enums.AlertStageEnums; import com.yeejoin.amos.boot.module.elevator.api.enums.AlertStageEnums;
import com.yeejoin.amos.boot.module.elevator.api.service.IMaintenanceUnitService;
import com.yeejoin.amos.boot.module.elevator.api.service.IUseUnitService;
import com.yeejoin.amos.boot.module.elevator.api.service.TzsAuthService; import com.yeejoin.amos.boot.module.elevator.api.service.TzsAuthService;
import com.yeejoin.amos.boot.module.elevator.biz.utils.AlertBeanDtoVoUtils; import com.yeejoin.amos.boot.module.elevator.biz.utils.AlertBeanDtoVoUtils;
import com.yeejoin.amos.boot.module.elevator.biz.utils.BeanDtoVoUtils; import com.yeejoin.amos.boot.module.elevator.biz.utils.BeanDtoVoUtils;
import com.yeejoin.amos.component.feign.utils.FeignUtil;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -41,6 +40,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -41,6 +40,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
...@@ -50,7 +50,6 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -50,7 +50,6 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import java.util.*; import java.util.*;
/** /**
...@@ -123,23 +122,23 @@ public class AlertCalledController extends BaseController { ...@@ -123,23 +122,23 @@ public class AlertCalledController extends BaseController {
if (ValidationUtil.isEmpty(alertCalledObjsDto)) { if (ValidationUtil.isEmpty(alertCalledObjsDto)) {
throw new BadRequest("参数校验失败."); throw new BadRequest("参数校验失败.");
} }
//切换数据源 //切换数据源
// LambdaQueryWrapper<Elevator> queryWrapper = new LambdaQueryWrapper<>(); //LambdaQueryWrapper<Elevator> queryWrapper = new LambdaQueryWrapper<>();
// queryWrapper.eq(Elevator::getRescueCode,alertCalledObjsDto.getAlertCalledDto().getDeviceId()); //queryWrapper.eq(Elevator::getRescueCode,alertCalledObjsDto.getAlertCalledDto().getDeviceId());
Elevator elevator = new Elevator(); Elevator elevator = new Elevator();
elevator.setRescueCode(Integer.valueOf(alertCalledObjsDto.getAlertCalledDto().getDeviceId())); elevator.setRescueCode(Integer.valueOf(alertCalledObjsDto.getAlertCalledDto().getDeviceId()));
Map<String,Object> map = iElevatorService.selectElevatorList(elevator); Map<String,Object> map = iElevatorService.selectElevatorList(elevator);
if(ObjectUtils.isEmpty(map)) { if(ObjectUtils.isEmpty(map)) {
throw new BadRequest("未找到相关电梯."); throw new BadRequest("未找到相关电梯.");
} }
List<AgencyUserModel> userModels = FeignUtil.remoteCall(()->Privilege.agencyUserClient.queryByIds(RequestContext.getExeUserId(),false));
ReginParams reginParams = getSelectedOrgInfo(); //由于查询的当前登录的用户信息 所以一定有 未作冗余判空
alertCalledObjsDto = iAlertCalledService.createAlertCalled(alertCalledObjsDto, reginParams.getUserModel()); AgencyUserModel userModel = userModels.get(0);
alertCalledObjsDto = iAlertCalledService.createAlertCalled(alertCalledObjsDto, userModel);
// 坐席接警后,辅屏由常态化切换为处置态 // 坐席接警后,辅屏由常态化切换为处置态
AgencyUserModel user =getUserInfo();
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("userId",user.getUserId()); jsonObject.put("userId",userModel.getUserId());
jsonObject.put("alertId",String.valueOf(alertCalledObjsDto.getAlertCalledDto().getSequenceNbr())); jsonObject.put("alertId",String.valueOf(alertCalledObjsDto.getAlertCalledDto().getSequenceNbr()));
JSONObject jsonObject1 = new JSONObject(); JSONObject jsonObject1 = new JSONObject();
...@@ -294,40 +293,19 @@ public class AlertCalledController extends BaseController { ...@@ -294,40 +293,19 @@ public class AlertCalledController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getWorkOderNumber") @GetMapping(value = "/getWorkOderNumber")
@ApiOperation(httpMethod = "GET", value = "生成工单编号报警人及报警时间", notes = "生成工单编号报警人及报警时间") @ApiOperation(httpMethod = "GET", value = "生成工单编号报警人及报警时间", notes = "生成工单编号报警人及报警时间")
public ResponseModel<AlertCallInfoDto> selectOne() throws ParseException { public ResponseModel<AlertCallInfoDto> selectOne() {
String workOrderNumber = nextId(); List<AgencyUserModel> userModels = FeignUtil.remoteCall(()->Privilege.agencyUserClient.queryByIds(RequestContext.getExeUserId(),false));
//由于查询的当前登录的用户信息 所以一定有 未作冗余判空
AgencyUserModel userModel = userModels.get(0);
String workOrderNumber = iAlertCalledService.nextId();
AlertCallInfoDto alertCallInfoDto = new AlertCallInfoDto(); AlertCallInfoDto alertCallInfoDto = new AlertCallInfoDto();
alertCallInfoDto.setCallTime(DateUtils.stampToDate(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss ")); alertCallInfoDto.setCallTime(DateUtils.stampToDate(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss "));
alertCallInfoDto.setWorkOrderNumber(workOrderNumber); alertCallInfoDto.setWorkOrderNumber(workOrderNumber);
alertCallInfoDto.setRecUserId(getUserInfo().getUserId()); alertCallInfoDto.setRecUserId(userModel.getUserId());
alertCallInfoDto.setRecUserName(getUserInfo().getRealName()); alertCallInfoDto.setRecUserName(userModel.getRealName());
return ResponseHelper.buildResponse(alertCallInfoDto); return ResponseHelper.buildResponse(alertCallInfoDto);
} }
/**
* 获取下一个 工单编号
*
* @return 下一个 工单编号
*/
public synchronized String nextId() throws ParseException {
String number = DateUtils.stampToDate(SystemClock.now(), "yyyy-MM-dd HH:mm:ss SSS");
String newNumber = number.replace("-", "").replace(" ", "").replace(":", "");
ReginParams reginParams = getSelectedOrgInfo();
AgencyUserModel user = reginParams.getUserModel();
String orgCode = ValidationUtil.isEmpty(user.getCompanys()) ? null : user.getCompanys().get(0).getOrgCode();
Map<String, Object> map = iAlertCalledService.getAlertInfoList(
DateUtils.stampToDate(System.currentTimeMillis(), DateUtils.DATE_TIME_PATTERN),
DateUtils.stampToDate(System.currentTimeMillis(), DateUtils.DATE_TIME_PATTERN), orgCode,
user.getUserId());
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(newNumber);
String workOrderNumber = stringBuilder.append(map.get("calledCount") == null ? "1"
: String.valueOf(Integer.parseInt(map.get("calledCount").toString()) + 1)).toString();
return workOrderNumber;
}
/** /**
* 警情统计 * 警情统计
......
...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray; ...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.SystemClock;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
...@@ -46,17 +47,24 @@ import org.apache.commons.lang.text.StrBuilder; ...@@ -46,17 +47,24 @@ import org.apache.commons.lang.text.StrBuilder;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.redisson.api.RAtomicLong;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -131,6 +139,17 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall ...@@ -131,6 +139,17 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
@Value("${duty.seats.role.ids}") @Value("${duty.seats.role.ids}")
private String dutySeatsRoleIds; private String dutySeatsRoleIds;
private RedissonClient redissonClient;
private RAtomicLong rAtomicLong;
public AlertCalledServiceImpl(RedissonClient client){
this.redissonClient = client;
rAtomicLong = redissonClient.getAtomicLong("AUTO_INCR_LONG");
}
private final Logger logger = LogManager.getLogger(AlertCalledServiceImpl.class); private final Logger logger = LogManager.getLogger(AlertCalledServiceImpl.class);
...@@ -816,7 +835,41 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall ...@@ -816,7 +835,41 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
public Integer getEquipmentHistoryCount(List<String> useRegionCode, String equipmentClassCode, String equipmentCode) { public Integer getEquipmentHistoryCount(List<String> useRegionCode, String equipmentClassCode, String equipmentCode) {
return baseMapper.getEquipmentHistoryCount(useRegionCode,equipmentClassCode,equipmentCode); return baseMapper.getEquipmentHistoryCount(useRegionCode,equipmentClassCode,equipmentCode);
} }
// 今日值班人员接警数量统计
@Override
public String nextId() {
RLock lock = redissonClient.getLock("WORK_ORDER_NUMBER_LOCK_KEY");
String workOrderNumber = "";
try {
lock.lock();
long remainTimeToLive = rAtomicLong.remainTimeToLive();
// 判断是否过期,设置过期时间,序列开始重置为0
if (remainTimeToLive <= 0) {
resetCounterAndExpire();
}
long seq = rAtomicLong.incrementAndGet();
String number = DateUtils.stampToDate(SystemClock.now(), "yyyyMMddHHmmss");
workOrderNumber = number + seq;
} finally {
lock.unlock();
}
return workOrderNumber;
}
private void resetCounterAndExpire() {
// 第二天凌晨序列重置 新开始
rAtomicLong.set(0);
rAtomicLong.expireAt(calculateExpirationTime());
}
private long calculateExpirationTime() {
LocalDateTime now = LocalDateTime.now();
LocalDateTime nextDay = now.plus(1, ChronoUnit.DAYS).withHour(0).withMinute(0).withSecond(0).withNano(0);
return nextDay.toInstant(ZoneOffset.of("+0")).toEpochMilli();
}
// 今日值班人员接警数量统计
public Integer countNum(String userName){ public Integer countNum(String userName){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String format = simpleDateFormat.format(new Date()); String format = simpleDateFormat.format(new Date());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment