海外平台-数据全英文化
This commit is contained in:
@ -6,6 +6,7 @@ import com.ho.flow.vo.Event;
|
||||
import com.ho.flow.vo.req.AlarmConfig.AlarmConfigQueryVo;
|
||||
import com.ho.flow.vo.req.event.EventNumReq;
|
||||
import com.ho.flow.vo.req.event.EventReqPageVO;
|
||||
import com.ho.flow.vo.EventVo;
|
||||
import com.ho.flow.vo.resp.event.EventDayNum;
|
||||
import com.ho.flow.vo.resp.event.EventLevelNum;
|
||||
import com.ho.flow.vo.resp.event.EventRespVO;
|
||||
@ -73,4 +74,10 @@ public interface EventMapper {
|
||||
int deleteByParam(@Param("vo") Event vo);
|
||||
|
||||
List<Integer> eventDeviceNum(@Param("vo") EventNumReq vo);
|
||||
|
||||
|
||||
List<EventVo> selectTableList(@Param("tableName") String tableName, @Param("name") String name, @Param("nameEn") String nameEn);
|
||||
|
||||
int updateNameEnById(@Param("id") long id, @Param("tableName") String tableName,@Param("nameEn") String nameEn,@Param("translateName") String translateName);
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
package com.ho.flow.mapper;
|
||||
|
||||
import com.ho.business.entity.TranslateName;
|
||||
import com.ho.business.vo.resp.dynamicConfig.PointConfigResp;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author kerwin
|
||||
*/
|
||||
@Mapper
|
||||
public interface TranslateNameMapper {
|
||||
|
||||
|
||||
List<TranslateName> getDictNation();
|
||||
|
||||
TranslateName selectNameEN(@Param("name")String name);
|
||||
|
||||
int insert(@Param("vo")TranslateName vo);
|
||||
|
||||
int updateNameEnById(@Param("id") Integer id, @Param("nameEn") String nameEn);
|
||||
|
||||
|
||||
}
|
||||
@ -96,4 +96,12 @@ public interface EventService {
|
||||
List<EventDayNum> countEventByDay(EventReqPageVO vo);
|
||||
|
||||
Map<String,Integer> eventDeviceNum(EventNumReq vo);
|
||||
|
||||
/**
|
||||
* 修改点名称英文
|
||||
* @return
|
||||
*/
|
||||
int updatePointNameEn(String tableName,String name,String nameEn);
|
||||
|
||||
String getNameEn(String name);
|
||||
}
|
||||
|
||||
@ -25,14 +25,17 @@ import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.PageResult;
|
||||
import com.ho.common.tools.util.PageUtils;
|
||||
import com.ho.common.tools.util.TranslateUtils;
|
||||
import com.ho.flow.constant.FlowConstant;
|
||||
import com.ho.flow.constant.WorkOrderConstant;
|
||||
import com.ho.flow.entity.process.MovementDTO;
|
||||
import com.ho.flow.feignclient.BusinessFeignClient;
|
||||
import com.ho.flow.mapper.EventMapper;
|
||||
import com.ho.flow.mapper.TranslateNameMapper;
|
||||
import com.ho.flow.monitor.EventToProcessMonitor;
|
||||
import com.ho.flow.service.*;
|
||||
import com.ho.flow.vo.Event;
|
||||
import com.ho.flow.vo.EventVo;
|
||||
import com.ho.flow.vo.WorkOrderCirculation;
|
||||
import com.ho.flow.vo.WorkOrderOld;
|
||||
import com.ho.flow.vo.req.AlarmConfig.AlarmConfigQueryVo;
|
||||
@ -41,6 +44,7 @@ import com.ho.flow.vo.req.event.*;
|
||||
import com.ho.flow.vo.req.workorder.DoTaskReq;
|
||||
import com.ho.flow.vo.req.workorder.WorkOrderAddReqVO;
|
||||
import com.ho.flow.vo.resp.event.*;
|
||||
import jodd.util.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@ -50,6 +54,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -89,6 +94,9 @@ public class EventServiceImpl implements EventService {
|
||||
@Value("${station.outSideMinute}")
|
||||
Integer outSideMinute;
|
||||
|
||||
@Autowired
|
||||
TranslateNameMapper translateNameMapper;
|
||||
|
||||
EventToProcessMonitor monitor = new EventToProcessMonitor();
|
||||
|
||||
//事件转工单
|
||||
@ -182,6 +190,7 @@ public class EventServiceImpl implements EventService {
|
||||
if (!stationIdList.isEmpty()) {
|
||||
DeviceReqVO deviceReqVO = new DeviceReqVO();
|
||||
deviceReqVO.setStationIds(stationIdList);
|
||||
deviceReqVO.setLang(vo.getLang());
|
||||
DataResult<List<Device>> result = businessFeignClient.selectDeviceByStationIds(deviceReqVO);
|
||||
List<Device> deviceList = result.getData();
|
||||
idDeviceNameMap = deviceList.stream().collect(Collectors.toMap(d -> d.getSrcId() + "-" + d.getStationId(), Function.identity(), (d1, d2) -> d1));
|
||||
@ -523,6 +532,7 @@ public class EventServiceImpl implements EventService {
|
||||
pageVO.setStatus(CommonConstant.ZERO);
|
||||
}
|
||||
pageVO.setLimitCount(100);
|
||||
pageVO.setLang(req.getLang());
|
||||
List<EventRespVO> eventRespVOS = eventList(pageVO);
|
||||
|
||||
List<EventRespVO> list = new ArrayList<>(100);
|
||||
@ -640,6 +650,7 @@ public class EventServiceImpl implements EventService {
|
||||
//设置为告警数据
|
||||
snEvent.setIsRecovery(0);
|
||||
snEvent.setDescription(name + CommonConstant.Heartbeat.STATION_FAIL);
|
||||
snEvent.setDescriptionEn(getNameEn(snEvent.getDescription()));
|
||||
events.add(snEvent);
|
||||
sendSmsConfigService.sendSms(vo);
|
||||
} else { //如果告警事件存在且该数据的告警已恢复,则产生告警数据
|
||||
@ -648,6 +659,7 @@ public class EventServiceImpl implements EventService {
|
||||
//设置为告警数据
|
||||
snEvent.setIsRecovery(0);
|
||||
snEvent.setDescription(name + CommonConstant.Heartbeat.STATION_FAIL);
|
||||
snEvent.setDescriptionEn(getNameEn(snEvent.getDescription()));
|
||||
events.add(snEvent);
|
||||
sendSmsConfigService.sendSms(vo);
|
||||
}
|
||||
@ -671,6 +683,7 @@ public class EventServiceImpl implements EventService {
|
||||
snEvent.setConfirmTime(new Date());
|
||||
snEvent.setConfirmMan(FlowConstant.DEFAULT_CONFIRM_MAN);
|
||||
snEvent.setDescription(name + CommonConstant.Heartbeat.STATION_FAIL + "恢复");
|
||||
snEvent.setDescriptionEn(getNameEn(snEvent.getDescription()));
|
||||
events.add(snEvent);
|
||||
//确认前一条告警数据
|
||||
Event beforeEvent = new Event();
|
||||
@ -750,6 +763,7 @@ public class EventServiceImpl implements EventService {
|
||||
snEvent.setConfirmMan(FlowConstant.DEFAULT_CONFIRM_MAN);
|
||||
snEvent.setConfirmTime(updateTime);
|
||||
snEvent.setDescription(CommonConstant.OutsideEle.SUCCESS);
|
||||
snEvent.setDescriptionEn(getNameEn(snEvent.getDescription()));
|
||||
events.add(snEvent);
|
||||
//确认前一条告警数据
|
||||
Event beforeEvent = new Event();
|
||||
@ -939,6 +953,7 @@ public class EventServiceImpl implements EventService {
|
||||
snEvent.setSignal(sn);
|
||||
snEvent.setStatus(CommonConstant.STATUS);
|
||||
snEvent.setDescription(sn + CommonConstant.Heartbeat.SN_FAIL);
|
||||
snEvent.setDescriptionEn(getNameEn(snEvent.getDescription()));
|
||||
snEvent.setConfirmStatus(CommonConstant.STATUS);
|
||||
snEvent.setCreateTime(date);
|
||||
return snEvent;
|
||||
@ -966,6 +981,7 @@ public class EventServiceImpl implements EventService {
|
||||
snEvent.setSignal(DeviceTypeConstant.OUTSIDE_ELE);
|
||||
snEvent.setStatus(CommonConstant.STATUS);
|
||||
snEvent.setDescription(CommonConstant.OutsideEle.FAIL);
|
||||
snEvent.setDescriptionEn(getNameEn(snEvent.getDescription()));
|
||||
snEvent.setConfirmStatus(CommonConstant.STATUS);
|
||||
snEvent.setCreateTime(date);
|
||||
return snEvent;
|
||||
@ -1152,6 +1168,51 @@ public class EventServiceImpl implements EventService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updatePointNameEn(String tableName,String name,String nameEn) {
|
||||
int a=0;
|
||||
//查询所有name_en 为空的数据
|
||||
List<EventVo> list = eventMapper.selectTableList(tableName,name,nameEn);
|
||||
for (EventVo vo:list){
|
||||
if(StringUtil.isNotBlank(vo.getName())){
|
||||
String translateName = getNameEn(vo.getName());
|
||||
int resoult=eventMapper.updateNameEnById(vo.getId(),tableName,nameEn,translateName);
|
||||
a=a+resoult;
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameEn(String name) {
|
||||
// 查询数据库中有预先翻译的中文字段
|
||||
String nameEn = null;
|
||||
TranslateName vo = translateNameMapper.selectNameEN(name);
|
||||
if(vo == null){
|
||||
nameEn = TranslateUtils.translate(name);
|
||||
// 插入中文预翻译表
|
||||
TranslateName translate = new TranslateName();
|
||||
translate.setName(name);
|
||||
translate.setNameEn(nameEn);
|
||||
CompletableFuture.runAsync(()->{
|
||||
translateNameMapper.insert(translate);
|
||||
});
|
||||
}else{
|
||||
if(StringUtil.isEmpty(vo.getNameEn())){
|
||||
nameEn = TranslateUtils.translate(name);
|
||||
String finalNameEn = nameEn;
|
||||
CompletableFuture.runAsync(()->{
|
||||
translateNameMapper.updateNameEnById(vo.getId(), finalNameEn);
|
||||
});
|
||||
}else{
|
||||
nameEn = vo.getNameEn();
|
||||
}
|
||||
}
|
||||
return nameEn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,14 @@
|
||||
|
||||
<select id="selectByInfo" resultType="com.ho.flow.vo.resp.event.EventRespVO">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
<choose>
|
||||
<when test="record.lang != null and record.lang=='en_US' ">
|
||||
<include refid="Base_Column_List1"/>
|
||||
</when>
|
||||
<otherwise>
|
||||
<include refid="Base_Column_List"/>
|
||||
</otherwise>
|
||||
</choose>
|
||||
from event
|
||||
<where>
|
||||
<if test="record.targetDevice != null">
|
||||
@ -160,6 +167,17 @@
|
||||
category,type,sub_type,sens_type,is_recovery,before_event_id
|
||||
</sql>
|
||||
|
||||
<sql id="Base_Column_List1">
|
||||
id
|
||||
,station_id,dept_id,group_id,
|
||||
event_type,event_level,time_stamp,
|
||||
target_device,device_type, device_type_id, `signal`,`status`,
|
||||
value,description_en description ,confirm_status,
|
||||
confirm_man,confirm_time,remark,
|
||||
suggestion,create_time,update_time,
|
||||
category,type,sub_type,sens_type,is_recovery,before_event_id
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="selectByPrimaryKey" resultType="com.ho.flow.vo.Event">
|
||||
select
|
||||
@ -325,14 +343,14 @@
|
||||
id,station_id,dept_id,group_id,
|
||||
event_type,event_level,time_stamp,
|
||||
target_device,device_type, device_type_id,`signal`,status,
|
||||
`value`,`description`,confirm_status,
|
||||
`value`,`description`,description_en,confirm_status,
|
||||
confirm_man,confirm_time,remark,
|
||||
suggestion,category,type,sub_type,sens_type,is_recovery,before_event_id
|
||||
) values(
|
||||
#{id},#{stationId},#{deptId},#{groupId},
|
||||
#{eventType},#{eventLevel},#{timeStamp},
|
||||
#{targetDevice},#{deviceType}, #{deviceTypeId},#{signal},#{status},
|
||||
#{value},#{description},#{confirmStatus},
|
||||
#{value},#{description},#{descriptionEn},#{confirmStatus},
|
||||
#{confirmMan},#{confirmTime},#{remark},
|
||||
#{suggestion},#{category},#{type},#{subType},#{sensType},#{isRecovery},#{beforeEventId}
|
||||
)
|
||||
@ -403,7 +421,7 @@
|
||||
id,station_id,dept_id,group_id,
|
||||
event_type,event_level,time_stamp,
|
||||
target_device,device_type, device_type_id,`signal`,status,
|
||||
`value`,`description`,confirm_status,
|
||||
`value`,`description`,description_en,confirm_status,
|
||||
confirm_man,confirm_time,remark,
|
||||
suggestion,category,type,sub_type,sens_type,is_recovery,before_event_id
|
||||
)
|
||||
@ -413,7 +431,7 @@
|
||||
#{item.id},#{item.stationId},#{item.deptId},#{item.groupId},
|
||||
#{item.eventType},#{item.eventLevel},#{item.timeStamp},
|
||||
#{item.targetDevice},#{item.deviceType}, #{item.deviceTypeId},#{item.signal},#{item.status},
|
||||
#{item.value},#{item.description},#{item.confirmStatus},
|
||||
#{item.value},#{item.description},#{item.descriptionEn},#{item.confirmStatus},
|
||||
#{item.confirmMan},#{item.confirmTime},#{item.remark},
|
||||
#{item.suggestion},#{item.category},#{item.type},#{item.subType},#{item.sensType},#{item.isRecovery},#{item.beforeEventId}
|
||||
)
|
||||
@ -431,6 +449,9 @@
|
||||
<if test="event.description != null">
|
||||
description = #{event.description,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="event.descriptionEn != null">
|
||||
description_en = #{event.descriptionEn,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="event.updateTime != null">
|
||||
update_time = #{event.updateTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
@ -778,4 +799,14 @@
|
||||
<select id="eventDeviceNum" resultType="java.lang.Integer">
|
||||
SELECT count(0) faultDevice FROM event where status = 0 and station_id = #{vo.stationId} group by target_device
|
||||
</select>
|
||||
|
||||
<select id="selectTableList" resultType="com.ho.flow.vo.EventVo">
|
||||
select
|
||||
id,${name} name
|
||||
from ${tableName} where (${nameEn} is null or ${nameEn}='') and ${name} is not null
|
||||
</select>
|
||||
|
||||
<update id="updateNameEnById">
|
||||
update ${tableName} set ${nameEn}=#{translateName} where id = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ho.flow.mapper.TranslateNameMapper">
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,`name`,name_en
|
||||
</sql>
|
||||
|
||||
<select id="getDictNation" resultType="com.ho.business.entity.TranslateName">
|
||||
select <include refid="Base_Column_List"/> from translate_name
|
||||
</select>
|
||||
|
||||
<select id="selectNameEN" resultType="com.ho.business.entity.TranslateName">
|
||||
select <include refid="Base_Column_List"/> from translate_name where name = #{name} limit 1
|
||||
</select>
|
||||
|
||||
<update id="updateNameEnById">
|
||||
update translate_name set name_en=#{nameEn} where id = #{id}
|
||||
</update>
|
||||
|
||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.TranslateName"
|
||||
useGeneratedKeys="true">
|
||||
insert into translate_name
|
||||
( id, name, name_en)
|
||||
values ( #{vo.id,jdbcType=INTEGER}, #{vo.name,jdbcType=VARCHAR}, #{vo.nameEn,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user