Commit 08d3fbd3 authored by zhangyingbin's avatar zhangyingbin

修改特种设备问题

parent 83ef4276
......@@ -5,9 +5,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.annotations.DataAuth;
import com.yeejoin.amos.boot.module.tzs.api.dto.TzsJgBasicInfoDto;
import java.util.Set;
public interface TzsJgMapper {
@DataAuth(interfacePath = "equipment")
IPage<TzsJgBasicInfoDto> page(Page<TzsJgBasicInfoDto> page, TzsJgBasicInfoDto tzsJgBasicInfoDto);
IPage<TzsJgBasicInfoDto> page(Page<TzsJgBasicInfoDto> page, TzsJgBasicInfoDto tzsJgBasicInfoDto, Set<String> categoryCodes);
}
......@@ -14,13 +14,14 @@
use1.estate_unit_name,
registration.equ_code,
registration.equ_category,
registration.equ_define,
ec.`name` AS equ_define,
registration.equ_define AS equ_define_code,
other.code96333,
registration.use_org_code,
produce.factory_num,
CONCAT(use1.province,'/',use1.city,'/',use1.county)AS area,
use1.address
FROM tz_jg_use_info use1
FROM tz_jg_use_info use1
LEFT JOIN
tz_jg_supervise_info supervise ON use1.sequence_code =
supervise.sequence_code
......@@ -37,7 +38,19 @@
LEFT JOIN
tz_jg_produce_info produce ON produce.sequence_code =
supervise.sequence_code
LEFT JOIN tz_equipment_category ec ON ec.`code` = registration.equ_define
<where>
<if test="categoryCodes != null and categoryCodes.size>0">
and ( registration.equ_define in
<foreach collection="categoryCodes" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
or registration.equ_category in
<foreach collection="categoryCodes" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
)
</if>
<if
test="tzsJgBasicInfoDto.orgBranchCode!=null and tzsJgBasicInfoDto.orgBranchCode!='' ">
AND supervise.org_branch_code LIKE
......@@ -69,16 +82,6 @@
CONCAT('%',#{tzsJgBasicInfoDto.equCode},'%')
</if>
<if
test="tzsJgBasicInfoDto.equCategory!=null and tzsJgBasicInfoDto.equCategory!='' ">
AND registration.equ_category LIKE
CONCAT('%',#{tzsJgBasicInfoDto.equCategory},'%')
</if>
<if
test="tzsJgBasicInfoDto.equDefine!=null and tzsJgBasicInfoDto.equDefine!='' ">
AND registration.equ_define LIKE
CONCAT('%',#{tzsJgBasicInfoDto.equDefine},'%')
</if>
<if
test="tzsJgBasicInfoDto.code96333!=null and tzsJgBasicInfoDto.code96333!='' ">
AND other.code96333 LIKE
CONCAT('%',#{tzsJgBasicInfoDto.code96333},'%')
......
......@@ -4,12 +4,15 @@ import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.tzs.api.dto.WarningMsgDto;
import com.yeejoin.amos.boot.module.tzs.api.enums.WarningEnum;
import liquibase.pro.packaged.L;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -31,6 +34,7 @@ import com.yeejoin.amos.boot.module.tzs.biz.service.impl.WechatServiceImpl;
import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.CylinderInfoServiceImpl;
import com.yeejoin.amos.component.rule.RuleActionBean;
import com.yeejoin.amos.component.rule.RuleMethod;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
@Component
@RuleActionBean(beanLabel = "预警消息")
......@@ -57,12 +61,23 @@ public class WarningMsgAction{
public void sendWebMessageTip(Object bizobj, String level,String orgUserName,String phone ,String text)
{
WarningMsgDto warningMsgDto = (WarningMsgDto)bizobj;
List<MsgLog> msgLogList = msgLogServiceImpl.list(new LambdaQueryWrapper<MsgLog>().eq(MsgLog::getRelationCode,warningMsgDto.getCode()).eq(MsgLog :: getMsgTypeName,WarningEnum.getEumByLevel(level).getName()).eq(MsgLog::getIsDelete,false));
if(!ValidationUtil.isEmpty(msgLogList)){
logger.info("气瓶唯一标识码为 "+warningMsgDto.getCode()+" 的气瓶已有数据!");
return;
}
//更新气瓶等级
// logger.info("更新气瓶等级:"+level);
// logger.info("预警区间:"+warningMsgDto.getNum());
// cylinderInfoServiceImpl.updateEarlyWarningLevel(warningMsgDto.getCylSeq(), level);
//增加消息日志数据
MsgLog msgLog = new MsgLog();
MsgLog msgLog = msgLogServiceImpl.getOne(new LambdaQueryWrapper<MsgLog>().eq(MsgLog::getRelationCode,warningMsgDto.getCode()).eq(MsgLog::getIsDelete,false));
if(ValidationUtil.isEmpty(msgLog)){
msgLog = new MsgLog();
}
msgLog.setRelationCode(warningMsgDto.getCode());
msgLog.setMsgType(WarningEnum.getEumByLevel(level).getCode());
msgLog.setMsgTypeName(WarningEnum.getEumByLevel(level).getName());
......@@ -74,7 +89,7 @@ public class WarningMsgAction{
msgLog.setTerminalType("WEB");
msgLog.setSendTime(new Date());
msgLog.setRecDate(new Date());
msgLogServiceImpl.save(msgLog);
msgLogServiceImpl.saveOrUpdate(msgLog);
logger.info("增加消息日志数据:"+msgLog.toString());
//发送web消息
try {
......
......@@ -153,11 +153,7 @@ public class MsgLogController extends BaseController {
Page<MsgLogDto> page = new Page<>();
page.setCurrent(current);
page.setSize(size);
Page<MsgLogDto> msgLogDtoPage = msgLogServiceImpl.queryForMsgLogByTerminalTypePage(page, terminalType, isRead, sendTimeStart, sendTimeEnd, msgType, body);
List<MsgLogDto> records = msgLogDtoPage.getRecords( );
List<MsgLogDto> collect = records.stream( ).sorted(Comparator.comparing(MsgLogDto::getSendTime, Comparator.nullsLast(Comparator.reverseOrder( )))).collect(Collectors.toList( ));
msgLogDtoPage.setRecords(collect);
return ResponseHelper.buildResponse(msgLogDtoPage);
return ResponseHelper.buildResponse(msgLogServiceImpl.queryForMsgLogByTerminalTypePage(page, terminalType, isRead, sendTimeStart, sendTimeEnd, msgType, body));
}
/**
......
......@@ -106,6 +106,7 @@ public class MsgLogServiceImpl extends BaseService<MsgLogDto, MsgLog, MsgLogMapp
wrapper.le(StringUtils.hasText(sendTimeEnd), MsgLog::getSendTime, sendTimeEnd);
wrapper.eq(StringUtils.hasText(msgType), MsgLog::getMsgType, msgType);
wrapper.eq(MsgLog::getIsDelete, 0);
wrapper.orderByDesc(MsgLog::getSendTime);
wrapper.like(StringUtils.hasText(body), MsgLog::getBody, body);
page(msgLogPage, wrapper);
LinkedList<MsgLogDto> msgLogDtos = new LinkedList<>();
......
package com.yeejoin.amos.boot.module.tzs.biz.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -56,6 +55,7 @@ import com.yeejoin.amos.boot.module.tzs.api.service.ITzsJgUseInfoService;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
@Service
public class TzsJgServiceImpl implements ITzsJgService {
......@@ -109,6 +109,7 @@ public class TzsJgServiceImpl implements ITzsJgService {
@Override
public IPage<TzsJgBasicInfoDto> page(PageParam pageParam, TzsJgBasicInfoDto tzsJgBasicInfoDto) {
Set<String> categoryCodes = new HashSet<>();
if (tzsJgBasicInfoDto.getSuperviseKey() != null) {
FeignClientResult<CompanyModel> result = Privilege.companyClient
.seleteOne(Long.valueOf(tzsJgBasicInfoDto.getSuperviseKey()));
......@@ -116,17 +117,38 @@ public class TzsJgServiceImpl implements ITzsJgService {
tzsJgBasicInfoDto.setOrgBranchCode(result.getResult().getOrgCode());
}
}
if (tzsJgBasicInfoDto.getEquCategory() != null) {
EquipmentCategory equipmentCategory = equipmentCategoryServiceImpl
.getOne(new LambdaQueryWrapper<EquipmentCategory>().eq(EquipmentCategory::getId,
tzsJgBasicInfoDto.getEquCategory()));
if (equipmentCategory != null) {
tzsJgBasicInfoDto.setEquCategory(equipmentCategory.getCode().toString().replaceAll("0+$", ""));
}
if (tzsJgBasicInfoDto.getEquDefine() != null) {
// EquipmentCategory equipmentCategory = equipmentCategoryServiceImpl
// .getOne(new LambdaQueryWrapper<EquipmentCategory>().eq(EquipmentCategory::getId,
// tzsJgBasicInfoDto.getEquCategory()));
// if (equipmentCategory != null) {
// tzsJgBasicInfoDto.setEquCategory(equipmentCategory.getCode().toString().replaceAll("0+$", ""));
getCategoryCodes(tzsJgBasicInfoDto.getEquDefine(),categoryCodes);
// }
}
Page<TzsJgBasicInfoDto> page = new Page<>(pageParam.getCurrent(), pageParam.getSize());
return tzsJgMapper.page(page, tzsJgBasicInfoDto);
tzsJgMapper.page(page, tzsJgBasicInfoDto, categoryCodes);
for (TzsJgBasicInfoDto basicInfoDto:page.getRecords()){
if(ValidationUtil.isEmpty(basicInfoDto.getEquDefine())){
LambdaQueryWrapper<EquipmentCategory> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(EquipmentCategory :: getCode,basicInfoDto.getEquCategory());
basicInfoDto.setEquDefine(equipmentCategoryServiceImpl.getOne(wrapper).getName());
}
}
return page;
}
public Set<String> getCategoryCodes(String id,Set<String> categoryCodes){
categoryCodes.add(equipmentCategoryServiceImpl.getById(id).getCode());
LambdaQueryWrapper<EquipmentCategory> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(EquipmentCategory :: getParentId,id);
List<EquipmentCategory> equipmentCategoryList = equipmentCategoryServiceImpl.list(wrapper);
Iterator<EquipmentCategory> iterator = equipmentCategoryList.iterator();
while (iterator.hasNext()) {
getCategoryCodes(String.valueOf(iterator.next().getId()),categoryCodes);
}
return null;
}
@Override
......
......@@ -9,11 +9,13 @@ import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.tzs.api.dto.LicScheduleDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.WarningMsgDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.EquScheduleDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.MsgLog;
import com.yeejoin.amos.boot.module.tzs.api.entity.TzBaseUnitLicence;
import com.yeejoin.amos.boot.module.tzs.api.entity.TzsJgRegistrationInfo;
import com.yeejoin.amos.boot.module.tzs.api.enums.EarlyWarningLevelEnum;
import com.yeejoin.amos.boot.module.tzs.api.enums.WarningTypeEnum;
import com.yeejoin.amos.boot.module.tzs.api.mapper.ScheduleMapper;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.MsgLogServiceImpl;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.TzBaseUnitLicenceServiceImpl;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.TzsAuthServiceImpl;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.TzsJgRegistrationInfoServiceImpl;
......@@ -33,8 +35,10 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
/**
* @author Zhang Yingbin
......@@ -47,6 +51,9 @@ public class ScheduleService {
private ScheduleMapper scheduleMapper;
@Autowired
MsgLogServiceImpl msgLogServiceImpl;
@Autowired
TzsAuthServiceImpl tzsAuthService;
@Autowired
......@@ -140,6 +147,25 @@ public class ScheduleService {
if (log.isDebugEnabled()) {
log.debug("超期预警时间调用规则完成");
}
//检查msgLog中的消息,若下次检验日期已延续 则更新消息状态
List<MsgLog> msgLogList = msgLogServiceImpl.list(new LambdaQueryWrapper<MsgLog>().eq(MsgLog::getIsDelete,false));
Date now = new Date();
for(MsgLog msgLog:msgLogList){
msgLog.getRelationCode();
try {
CylinderInfoDto cylinderInfoDto = this.getCylDetail(msgLog.getRelationCode());
int interval = DateUtils.dateBetweenIncludeToday(now, cylinderInfoDto.getNextInspectionDate()) - 1;
if(interval>30){
msgLog.setIsDelete(true);
msgLog.setMsgTypeName("已延期");
msgLogServiceImpl.updateById(msgLog);
}
} catch (ParseException e) {
e.printStackTrace();
}
}
}
/**
......@@ -193,6 +219,7 @@ public class ScheduleService {
}
String[] test = new String[]{};
this.rulePublish(warningMsgDto,cylPackageId);
System.out.println("----------------------------------tzs服务调用了规则--------------------------------------");
} catch (Exception e) {
log.error("调用气瓶规则失败!:{},{}", JSON.toJSONString(cylinderInfoDto),e);
}
......
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